我想通过使用Zend Framework 2(更精确地说2.1.5)来实现RESTful Web服务。如果我访问http://ehcserver.localhost/rest,我得到了404,相应的消息是'rest(解析为无效的控制器类别或别名:rest)'。什么地方出了错?使用Zend Framework进行路由2 Restful Webservice
你可以看到我的源代码在我github上的存储库: https://github.com/Jochen1980/EhcServer/blob/master/module/Application/config/module.config.php
路线的定义是这样的:
return array(
'router' => array(
'routes' => array(
'rest' => array(
'type' => 'ZendMvcRouterHttpSegment',
'options' => array(
'route' => '/:controller[.:formatter][/:id]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'formatter' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[a-zA-Z0-9_-]*'
),
),
),
'home' => array(
...
你真的有一个'RestController'类在'YourModule/Controller'文件夹。如果是这样,是否将它映射到'module.config.php'中'controllers'数组的'invokables'部分?即'YourModule \ Controller \ Rest'=>'YourModule \ Controller \ RestController',' – Crisp 2013-05-03 14:39:42
感谢Crisp,你可以在我的仓库中看到,我认为我已经完成了这两项工作。还有什么建议吗? – Jochen 2013-05-03 14:59:28