Search code examples
phpsymfonydeprecatedknpmenubundle

Knp menu bundle warnings after update to symfony 2.3


After updating symfony from 2.2 to 2.3, i've got new stange errors on all my pages and in my scripts:

Deprecated: Knp\Menu\Silex\Voter\RouteVoter is deprecated because of namespace, use Knp\Menu\Matcher\Voter\RouteVoter instead. in \vendor\knplabs\knp-menu\src\Knp\Menu\Silex\Voter\RouteVoter.php on line 20

and

Deprecated: Knp\Menu\Silex\RoutingExtension is deprecated, use Knp\Menu\Integration\Symfony\RoutingExtension instead. in \vendor\knplabs\knp-menu\src\Knp\Menu\Silex\RoutingExtension.php on line 15

How could I fix this ? I don't find the answer on the web.
Thank you in advance

Here is my composer.json :

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.3.*",
        "doctrine/orm": ">=2.2.3,<2.4-dev",
        "doctrine/doctrine-bundle": "1.2.*",
        "twig/extensions": "1.0.*",
        "symfony/assetic-bundle": "2.3.*",
        "symfony/swiftmailer-bundle": "2.3.*",
        "symfony/monolog-bundle": "2.3.*",
        "sensio/distribution-bundle": "2.3.*",
        "sensio/framework-extra-bundle": "2.3.*",
        "sensio/generator-bundle": "2.3.*",
        "incenteev/composer-parameter-handler": "~2.0",
    "genemu/form-bundle": "2.1.*",
        "jms/security-extra-bundle": "1.5.*",
        "jms/di-extra-bundle": "1.4.*",
        "phpunit/phpunit": "3.7.*",
    "doctrine/data-fixtures": "@dev",
    "friendsofsymfony/user-bundle": "~2.0@dev",
    "stof/doctrine-extensions-bundle": "dev-master",
        "knplabs/gaufrette": "0.2.*@dev",
        "knplabs/knp-gaufrette-bundle":          "dev-master",
    "jms/serializer-bundle":                 "0.13.*@dev",
        "amazonwebservices/aws-sdk-for-php":     "dev-master",
        "punkave/symfony2-file-uploader-bundle": "dev-master",
        "oneup/uploader-bundle":                 "dev-master",
        "knplabs/knp-paginator-bundle":          "dev-master",
        "jms/debugging-bundle":                  "dev-master",
        "winzou/console-bundle":                 "dev-master",
        "elao/web-profiler-extra-bundle" :       "dev-master",
        "cybernox/amazon-webservices-bundle":    ">=1.5.4",
        "genemu/form-bundle":                    "2.2.*",
    "escapestudios/wsse-authentication-bundle": "2.3.x-dev",
        "rezzza/flickr-bundle":                  "1.0.*@dev",
        "knplabs/knp-menu-bundle":               "dev-master",
        "genemu/form-bundle":                    "2.1.*",
        "leaseweb/api-caller-bundle":        "*",
        "eo/honeypot-bundle":                    "dev-master"        
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "minimum-stability": "alpha",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        }, 
        "branch-alias": {
            "dev-master": "2.3-dev"
        }
    }
}

and my menu builder:

namespace ...\Menu;

use Knp\Menu\Matcher\Matcher;
use Knp\Menu\MenuFactory;
use Knp\Menu\Renderer\ListRenderer;

use Symfony\Component\DependencyInjection\ContainerAware;

class Builder extends ContainerAware
{
    public function mainMenu(MenuFactory $factory, array $options)
    {
        $menu = $factory->createItem('root');

        $menu->addChild('Dashboard', array(
                        'route' => 'dashboard' )); 
        $menu->addChild('Color Scheme', array(
                        'uri' => 'slidescheme' ));
        $menu->addChild('Questionnnaires', array(
                        'uri' => 'questionnaire_manage' ));
        // ... add more children

        return $menu;
    }
}

Solution

  • The issue is that you're using a dev version of knplabs/menu. Edit your composer file from:

    "knplabs/knp-menu-bundle":               "dev-master",
    

    to:

    "knplabs/knp-menu-bundle" :               "~1.1",
    

    and the error message will go away. Note that if you're actually using dev features of knplabs/menu (like Matcher and Voter) those won't be available any more. But Symfony does not require them anyway.