rest - Routing with Zend Framework 2 Restful Webservice -
i want implement restful webservice using zend framework 2, more precisely 2.1.5. got 404 if visit http://ehcserver.localhost/rest, corresponding message 'rest(resolves invalid controller class or alias: rest)'. went wrong?
you can see source code in github-repository: https://github.com/jochen1980/ehcserver/blob/master/module/application/config/module.config.php
the route defined this:
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( ...
your route doesn't define namespace controller belongs, need add __namespace__ route defaults
'rest' => array( 'type' => 'zendmvcrouterhttpsegment', 'options' => array( 'route' => '/:controller[.:formatter][/:id]', 'defaults' => array( // tell router namespace :controller belongs '__namespace__' => 'application\controller', ), 'constraints' => array( 'controller' => '[a-za-z][a-za-z0-9_-]*', 'formatter' => '[a-za-z][a-za-z0-9_-]*', 'id' => '[a-za-z0-9_-]*' ), ), ),
Comments
Post a Comment