Vista
Example
An example project to showcase Vistas workflow.
Project setup.
Layout
First create a layout file as views/layouts/main-layout.php
:
Home Page
Next, create a file that uses the layout views/home.php
:
Entry Point
Now, create a View and render it from your project main entry point, such as a typical public/index.php
:
Includes
You can use includes within any view relative to the root views’ folder. In this example, the layout file:
The include('sidebar', ['menu' => ['Home', 'About', 'Contact']])
method passes a menu variable to the sidebar.php
view.
Inside sidebar.php
, the $menu
array will be accessible.