PHP-DI / Silex-Bridge

PHP-DI integration in Silex
http://php-di.org/doc/frameworks/silex.html
MIT License
24 stars 8 forks source link

NotCallableException when adding controller to route #1

Closed dsazup closed 9 years ago

dsazup commented 9 years ago

Hello, I've been testing this package and what I usually do in silex is I have all controllers as classes. I define my routes like this:

$app = new Silex\Application();
$app['debug'] = true;
$app->get('/hello/{name}', 'Test\Controller::test');

It works perfectly in silex, however if I add this bridge to my app

$app = new DI\Bridge\Silex\Application();

$app['debug'] = true;
$app->get('/hello/{name}', 'Test\Controller::test');
$app->run();

I get NotCallableException in CallableReflection.php line 52: Test\Controller::test is not a callable Is there an easy way to solve this?

mnapoli commented 9 years ago

Ah yes PHP-DI supports this syntax for methods: ['Test\Controller', 'test'].

This isn't perfect because in PHP 'Test\Controller::test' is a valid callable, support for this should probably be added in PHP-DI. The reason I don't use this syntax so much is that with PHP 5.5 I can do: [Controller::class, 'test'].

mnapoli commented 9 years ago

FYI I just tagged 1.0 for this package.

dsazup commented 9 years ago

Thanks, looking forward to it.

mnapoli commented 9 years ago

I created https://github.com/PHP-DI/PHP-DI/issues/272, I'll keep track of this feature in the main repository. Thank you.

mnapoli commented 9 years ago

Hi, this feature was implemented in https://github.com/PHP-DI/Invoker/pull/3 you can run composer update and it should work!