Php 在zf3中为我的后端网站创建路由
我在module/config/module.config.php中有:Php 在zf3中为我的后端网站创建路由,php,zend-framework3,Php,Zend Framework3,我在module/config/module.config.php中有: 'router' => [ 'routes' => [ 'home-backend' => [ 'type' => Literal::class, 'options' => [ 'route' => '/backend', 'defaults' =
'router' => [
'routes' => [
'home-backend' => [
'type' => Literal::class,
'options' => [
'route' => '/backend',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],
'backend' => [
'type' => Segment::class,
'options' => [
'route' => '/backend[/:controller[/:action]]',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'wildcard' => [
'type' => 'Wildcard'
]
]
],
],
],
当我打电话时:
错误:
找不到页面。
请求的控制器无法映射到现有控制器类
控制器:
索引(解析为无效的控制器类或别名:index)
什么问题?您似乎错过了
控制器的配置。请将控制器的配置添加到module/config/module.config.php
如果使用工厂
,配置如下
'controllers' => [
'factories' => [
Controller\IndexController::class => Controller\IndexControllerFactory::class,
]
],
如果不使用工厂
,则配置如下
use Zend\ServiceManager\Factory\InvokableFactory;
return [
'controllers' => [
'factories' => [
Controller\IndexController::class => InvokableFactory::class,
]
],
]
您似乎错过了控制器的配置。请将控制器的配置添加到module/config/module.config.php
如果使用工厂
,配置如下
'controllers' => [
'factories' => [
Controller\IndexController::class => Controller\IndexControllerFactory::class,
]
],
如果不使用工厂
,则配置如下
use Zend\ServiceManager\Factory\InvokableFactory;
return [
'controllers' => [
'factories' => [
Controller\IndexController::class => InvokableFactory::class,
]
],
]
指出不应使用同一路线模式两次。这里我看到/backend
被使用了两次。否则,后端
路由的路由模式格式不正确
希望你能理解 指出您不应使用同一路线模式两次。这里我看到/backend
被使用了两次。否则,后端
路由的路由模式格式不正确
希望你能理解