Php Symfony2组件、加载控制器

Php Symfony2组件、加载控制器,php,symfony,routing,symfony-components,Php,Symfony,Routing,Symfony Components,我正在使用路由组件加载控制器,如果我只使用 $routes->add( 'index', new Route('/', array('_controller' => 'indexAction')) ); 我的“项目”完美地加载了索引函数,但如果我尝试这样的方法 $routes->add( 'index', new Route('/', array('_controller' => 'Test::indexAction')) ); 上面说

我正在使用路由组件加载控制器,如果我只使用

$routes->add(
    'index',
    new Route('/', array('_controller' => 'indexAction'))
);
我的“项目”完美地加载了索引函数,但如果我尝试这样的方法

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

Uncaught exception 'InvalidArgumentException' with message 'Class "Test" does not exist.'
但是我找不到我的控制器必须在哪里,或者它们必须如何被包含才能成功加载。
如果这有帮助的话,目前我正在使用composer autoload和PSR-0 standart。

就像Symfony doc上说的那样,你必须 使用以下模式命名控制器:

     bundle:controller:action
“完整”路径解决了问题

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

Test::indexAction更改为Levelup\Controller\Test::indexAction

类“Test”不存在。:)类“Levelup”不存在。DonCallisto提出了一个想法,我可能弄乱了名称空间更改为新路由(“/”,数组(“\u controller'=>“Levelup\\controller\\Test::indexAction”)),工作是否使用了名称空间?@DonCallisto,看起来像名称空间Levelup\controller;