質問

I am using routing component to load controllers, and if i use just

$routes->add(
    'index',
    new Route('/', array('_controller' => 'indexAction'))
);

my "project" perfectly loads indexAction function, but if i try something like this

$routes->add(
    'index',
    new Route('/', array('_controller' => 'Test::indexAction'))
);

it says

Uncaught exception 'InvalidArgumentException' with message 'Class "Test" does not exist.'

But i cant find where must be my controllers, or how they must be included to be loaded successfully. If this helps, at this moment i am using composer autoload with PSR-0 standart.

役に立ちましたか?

解決 2

"Full" path solved the problem

new Route('/', array('_controller' => 'Levelup\\Controller\\Test::indexAction'))

Test::indexAction changed to Levelup\Controller\Test::indexAction

他のヒント

Like its said on the Symfony doc about routing, you have to name your controller with this pattern :

     bundle:controller:action
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top