Skip to main content
Version: 13.x

Views

Views offer a convenient mechanism for organizing HTML content in separate files. They facilitate the separation of your controller or application logic from the presentation logic.

Definition and Principles​

Read Porto SAP Documentation (#Views).

Rules​

  • All container-specific Views MUST be placed in the app/Containers/{Section}/{Container}/UI/WEB/Views directory.
  • All general Views MUST be placed in the app/Ship/Views directory.

Folder Structure​

app
└── Containers
└── Section
└── Container
└── UI
└── WEB
└── Views
├── view-a.php
├── view-b.php
└── ...

Code Example​

Views are defined exactly as you would define them in Laravel.

View Loading​

Apiato is configured to load all view files in the app/Containers/{Section}/{Container}/UI/WEB/Views, app/Ship/Mails/Templates and app/Ship/Views directories.

If the default configuration does not suit your needs, you can customize it via the Apiato Configuration class.

Namespaces​

All views are namespaced using the camelCase of their Section name followed by @ and then the camelCase of their Container name.

For example, if you have a view named welcome-page in the app/Containers/MySection/MyContainer/UI/WEB/Views directory, you can access it like this: view(mySection@myContainer::welcome-page).

Attempting to access the view without the namespace, such as view('welcome-page'), will result in the view not being found.

An exception to this namespace convention is for view files located in the app/Ship/Views and app/Ship/Mails/Templates directories. These views will be namespaced using the word ship instead of the Section and Container names.

For example, you would access such a view like this: view(ship::welcome-page).

You may customize the namespace resolution logic via the Apiato Configuration class.