This bundle generate menu with from admin with KnpMenuBundle, SonataAdminBundle, and optional SkillbertoAdminBundle

2.2.2 2014-03-02 20:31 UTC


This bundle creates Menu into the template with KnpMenuBundle, so this bundle is neccessary. Also use SonataAdminBundle for admin generating. For more admin options include SkillbertoAdminBundle.

You have to download and configure those bundles too.


Step1: Download the bundle:

Using Composer: This is the prefered Symfony2 way.

Add the following lines in your composer.json:

    "require": {
        "skillberto/menu-bundle": "dev-master"

Using Git and deps file:

If you use git, you have to download other bundles too.


Now, run the vendors script to download the bundle:

$ php bin/vendors install

Using Git Submodules:

If you prefered this way with Git, run this:

$ git submodule add vendor/bundles/Skillberto/MenuBundle
$ git submodule update --init

Step2: Register the namespaces:

If you installed with composer, use the created autoload.php, and jump to step3, else use the following code:

// app/autoload.php
    // ...
    'Skillberto\MenuBundle' => __DIR__.'/../vendor/bundles',
    // ...

Step3: Register the bundle:

To start using the bundle, register it in you AppKernel.php:

// app/AppKernel.php

public function registerBundles()
    $bundles = array(
        // ...
        new Skillberto\MenuBundle\SkillbertoMenuBundle(),
    // ...

Step4: (optional) Configure the bundle:

The bundle uses Symfony2 DependencyInjection container, but SonataAdmin maybe needs some configuration.

skillberto_menu:    ~

#if you have blocks and groups in sonata_admin, add the following line to sonata_admin
            System: ~

Create your menu!

Create menu:

Go into admin (http://yourdomain/admin/dashboard), after that in the System group, Menu and Add new: (http://yourdomain/admin/skillberto/menu/menu/create)

This bundle uses Symfony2 RouteCollection class in the admin side. At the Route section you find existed routes, but not all. The controller filtered defaults the _..... routes ( dev ) and the the following removed_route too:


class MenuAdmin extends Admin
            // ...
            $removed_route = array(
            // ...

If you have SkillbertoAdminBundle, the system automatically adds Activate | Inactivate button into actions.

Rendering menu:

Put the following code into the template:

<div class="menu">
    {{ knp_menu_render('SkillbertoMenuBundle:Builder:mainMenu') }}