[英]Symfony2 components, loading controllers
我正在使用路由组件加载控制器,如果我只使用
$routes->add(
'index',
new Route('/', array('_controller' => 'indexAction'))
);
我的“项目”完美加载indexAction函数,但是如果我尝试这样的话
$routes->add(
'index',
new Route('/', array('_controller' => 'Test::indexAction'))
);
它说
Uncaught exception 'InvalidArgumentException' with message 'Class "Test" does not exist.'
但是我找不到控制器在哪里,或者必须如何包含它们才能成功加载。 如果有帮助,此刻,我正在使用带有PSR-0标准的作曲家自动加载功能。
就像它在Symfony文档中所说的关于路由一样 ,您必须使用以下模式来命名控制器:
bundle:controller:action
“全”路径解决了问题
new Route('/', array('_controller' => 'Levelup\\Controller\\Test::indexAction'))
测试:: indexAction更改为Levelup \\ Controller \\ Test :: indexAction
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.