Zend framework 3教程设置数据库后错误404:请求的控制器无法映射到现有控制器class
Zend framework 3 tutorial error 404 after setting database : The requested controller could not be mapped to an existing controller class
我正在为一个项目尝试 Zend Framework 3,我遵循了教程。设置路由和控制器后出现 404 错误,恰好在这部分的末尾:https://docs.zendframework.com/tutorials/getting-started/routing-and-controllers/
错误:
A 404 error occurred Page not found.
The requested controller could not be mapped to an existing controller
class.
Controller: Controller\AlbumController (resolves to invalid
controller class or alias: Controller\AlbumController)
No Exception available
我尝试了一些 Zend 2 修复,但它使情况变得更糟。
这是我的Album\config\module.config.php
return [
'router' => [
'routes' => [
'album' => [
'type' => Segment::class,
'options' => [
'route' => '/album[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\AlbumController::class,
'action' => 'index',
],
],
],
],
],
'view_manager' => [
'template_path_stack' => [
'album' => __DIR__ . '/../view',
],
],
];
我错过了什么吗?它坏了吗?
谢谢你帮助我。
好的,感谢@Ermenegildo,我明白了。问题所在 Module.php 缺少某些依赖项。
namespace Album;
use Zend\Db\Adapter\AdapterInterface;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
我正在为一个项目尝试 Zend Framework 3,我遵循了教程。设置路由和控制器后出现 404 错误,恰好在这部分的末尾:https://docs.zendframework.com/tutorials/getting-started/routing-and-controllers/
错误:
A 404 error occurred Page not found.
The requested controller could not be mapped to an existing controller class.
Controller: Controller\AlbumController (resolves to invalid controller class or alias: Controller\AlbumController)
No Exception available
我尝试了一些 Zend 2 修复,但它使情况变得更糟。
这是我的Album\config\module.config.php
return [
'router' => [
'routes' => [
'album' => [
'type' => Segment::class,
'options' => [
'route' => '/album[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\AlbumController::class,
'action' => 'index',
],
],
],
],
],
'view_manager' => [
'template_path_stack' => [
'album' => __DIR__ . '/../view',
],
],
];
我错过了什么吗?它坏了吗? 谢谢你帮助我。
好的,感谢@Ermenegildo,我明白了。问题所在 Module.php 缺少某些依赖项。
namespace Album;
use Zend\Db\Adapter\AdapterInterface;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\ModuleManager\Feature\ConfigProviderInterface;