PHP code example of lavary / menus

1. Go to this page and download the library: Download lavary/menus 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/ */

    

lavary / menus example snippets




use Lavary\Menus\MenuBuilder;

$builder = new MenuBuilder();

$builder->make('MyNavBar', function($menu) {
  
  $menu->add('Home');
  
  $menu->add('About', ['url' => 'about', 'class' => 'foo bar', 'data-role' => 'item'])->data('weight', 15);
  $menu->about->add('Goals', 'about/goals');
  
  $menu->add('services', 'services');
  $menu->add('Contact', 'contact');
  
});

echo $builder->get('myNavBar')->asBootstrap(['navbar-inverse']);

// or

echo $builder->get('myNavBar')->asUl();