Layout
First create a layout file asviews/layouts/main-layout.php
:
Home Page
Next, create a file that uses the layoutviews/home.php
:
Entry Point
Now, create a View and render it from your project main entry point, such as a typicalpublic/index.php
:
Includes
You can use includes within any view relative to the root views’ folder. In this example, the layout file: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.