PHP code example of phil / menu-bundle
1. Go to this page and download the library: Download phil/menu-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phil / menu-bundle example snippets
final class MainMenu implements MenuBuilder
{
public function name(): string
{
return 'main';
}
public function build(MenuContext $context): Menu
{
return Menu::of('main', [
MenuItem::of('home', 'Home')->withRoute('home'),
MenuItem::of('games', 'Games')->withRoute('games')->withChildren(
MenuItem::of('chess', 'Chess')->withRoute('game', ['slug' => 'chess']),
),
]);
}
}