PHP code example of blackator / vedi-menu-bundle

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

    

blackator / vedi-menu-bundle example snippets




namespace App\Controller;

use Blackator\Bundle\VediMenuBundle\Loaders\YamlMenuLoader;
use Blackator\Bundle\VediMenuBundle\Service\VediMenu;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class HomeController extends AbstractController
{
    /**
     * @Route("/", name="home")
     */
    public function index(VediMenu $vediMenu): Response
    {
        $menu = $vediMenu->create(new YamlMenuLoader($this->getParameter('kernel.project_dir') . '/config/menu/main_menu.yaml'), 'main');
        return $this->render('home/index.html.twig', ['menu' => $menu]);
    }
}