我使用以下 module.config.php 配置了 Resftul 模块(https://github.com/scaraveos/ZF2-Restful-Module-Skeleton)。但是当我想访问“public/rest/article.json”时,路由失败了。
有人对我有线索吗?控制器已给出。
return array(
'errors' => array(
'post_processor' => 'json-pp',
'show_exceptions' => array(
'message' => true,
'trace' => true
)
),
'di' => array(
'instance' => array(
'alias' => array(
'json-pp' => 'Rest\PostProcessor\Json',
'image-pp' => 'Rest\PostProcessor\Image',
)
)
),
'controllers' => array(
'invokables' => array(
'article' => 'Rest\Controller\ArticleController',
)
),
'router' => array(
'routes' => array(
'restful' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'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_-]*'
),
),
),
),
),
);
autoload_classmap 是
'Rest\Controller\ArticleController' => __DIR__ . '/src/Rest/Controller/ArticleController.php',