silexphp / Silex

[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components
https://silex.symfony.com
MIT License
3.58k stars 718 forks source link

Symfony Routing deprecated methods gives Notice errors #642

Closed cnkt closed 11 years ago

cnkt commented 11 years ago

When i try to use Service Controllers instead of closure functions like

$app->get('/', 'indexController:indexAction');

i get this notice:

Deprecated: addCollection() should only be used with a single parameter. The params $prefix, $defaults, $requirements and $options are deprecated since version 2.2 and will be removed in 2.3. Use addPrefix() and addOptions() instead. in E:\www\Wordy2\vendor\symfony\routing\Symfony\Component\Routing\RouteCollection.php on line 197
combro2k commented 11 years ago

Same issue here. I think its the issue is located in the src/Silex/Application.php:

https://github.com/fabpot/Silex/blob/master/src/Silex/Application.php#L367 https://github.com/fabpot/Silex/blob/master/src/Silex/Application.php#L465

/cc @fabpot

GromNaN commented 11 years ago

Can you provide a sample application to show the error ?

cnkt commented 11 years ago

Sample app:

<?php
mb_internal_encoding('UTF-8');
mb_detect_order(array('UTF-8', 'ASCII'));
mb_http_output('UTF-8');
date_default_timezone_set('UTC');

define('APP_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
define('APP_ROOT', __DIR__ . '/..');

require_once APP_ROOT . '/vendor/autoload.php';

$app = new Silex\Application();
$app['debug'] = true;
$app['charset'] = 'UTF-8';

$app->register(
        new Silex\Provider\ServiceControllerServiceProvider()
    );

$app['index.indexController'] = $app->share(function() {
    return new \App\Module\Index\Controller\IndexController();
});

$app->get('/', 'index.indexController:indexAction')->bind('index');

$app->run();
davedevelopment commented 11 years ago

Try using a stable version of symfony for now? Looks like this went in a couple of days ago.

cnkt commented 11 years ago

i just have "silex/silex": "1.0.*@dev", in my composer. How can i add stable version of symfony to it?

davedevelopment commented 11 years ago

@cnkt what about the rest of your composer.json? What is minimum-stability set to?

cnkt commented 11 years ago

I don't have minimum-stability section in my composer.json. Here is the full file:

{
    "require": {
        "silex/silex": "1.0.*@dev",
        "dflydev/doctrine-orm-service-provider": "1.0.x-dev",
        "breerly/zf1": "1.11.*",
        "doctrine/orm": "2.3.1",
        "michelf/php-markdown": "1.3.*@dev"
    },
    "autoload": {
        "psr-0": {
            "App": "src/"
        }
    }
}
combro2k commented 11 years ago
{
    "require": {
        "php":                    ">=5.3.3",
        "silex/silex":            "1.0.*",
        "symfony/monolog-bridge": "~2.2",
        "symfony/security":       "~2.2",
        "symfony/validator":      "~2.2",
        "kriswallsmith/buzz":     "dev-master"
    },
    "minimum-stability": "dev"
}
cnkt commented 11 years ago

I added minimum-stability but composer says this:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
mmuruev commented 11 years ago

I confirm the same problem. Deprecated: addCollection() should only be used with a single parameter. The params $prefix, $defaults, $requirements and $options are deprecated since version 2.2 and will be removed in 2.3. Use addPrefix() and addOptions() instead. in /vendor/symfony/routing/Symfony/Component/Routing/RouteCollection.php on line 197 After today composer update.

"require":{
    "php": ">=5.3.3",
    "silex/silex":"1.0.*",
fabpot commented 11 years ago

This should be fixed now.

cnkt commented 11 years ago

I can confirm this is fixed.

combro2k commented 11 years ago

Thank you very much it works as expected