Zend framework2 Zend Framework 2 MyTaskList教程问题

Zend framework2 Zend Framework 2 MyTaskList教程问题,zend-framework2,Zend Framework2,我正在尝试学习zend framework,我开始学习本教程: 当我完成本教程时,我发现我们在本教程中设置的路线是:http://localhost/MyTaskList/task应该获取所有任务,但实际返回404错误(未找到) 任何帮助都将不胜感激 这是我的档案: 这是mysql数据库脚本: CREATE TABLE task_item ( id INT NOT NULL AUTO_INCREMENT, title VARCHAR(100) NOT NULL, completed TINYIN

我正在尝试学习zend framework,我开始学习本教程:

当我完成本教程时,我发现我们在本教程中设置的路线是:
http://localhost/MyTaskList/task
应该获取所有任务,但实际返回404错误(未找到)

任何帮助都将不胜感激

这是我的档案:

这是mysql数据库脚本:

CREATE TABLE task_item (
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(100) NOT NULL,
completed TINYINT NOT NULL DEFAULT ’0’,
created DATETIME NOT NULL,
PRIMARY KEY (id)
);

INSERT INTO task_item (title, completed, created)
    VALUES (’Purchase conference ticket’, 0, NOW());
INSERT INTO task_item (title, completed, created)
    VALUES (’Book airline ticket’, 0, NOW());
INSERT INTO task_item (title, completed, created)
    VALUES (’Book hotel’, 0, NOW());
INSERT INTO task_item (title, completed, created)
    VALUES (’Enjoy conference’, 0, NOW());
更新

这是我的module.config.php:

return array(
'controllers' => array(
    'invokables' => array(
        'Checklist\Controller\Task' => 'Checklist\Controller\TaskController',
    ),
),
'router' => array(
    'routes' => array(
        'task' => array(
            'type'    => 'Segment',
            'options' => array(
                'route'    => '/task[/:action[/:id]]',
                'defaults' => array(
                    '__NAMESPACE__' => 'Checklist\Controller',
                    'controller'    => 'Task',
                    'action'        => 'index',
                ),
                'constraints' => array(
                    'action' => '^add|edit|delete$',
                    'id'     => '[0-9]+',
                ),
            ),
        ),
    ),
),
'may_terminate' => true,
'child_routes' => array(
        'default' => array(
                'type' => 'Segment',
                'options' => array(
                        'route' => '/[:controller[/:action]]'
                        , )
                , )
        , ),
'view_manager' => array(
    'template_path_stack' => array(
        'Checklist' => __DIR__ . '/../view',
    ),
),
);

url-localhost/MyTaskList/task

<?php
return array(
'controllers' => array(
    'invokables' => array(
        'Checklist\Controller\Task' => 'Checklist\Controller\TaskController',
    ),
),
'router' => array(
    'routes' => array(
        'task' => array(
            'type'    => 'Literal',
            'options' => array(
                'route'    => '/task',
                'defaults' => array(
                    '__NAMESPACE__' => 'Checklist\Controller',
                    'controller'    => 'Task',
                    'action'        => 'index',
                ),
                'constraints' => array(
                    'action' => '^add|edit|delete$',
                    'id'     => '[0-9]+',
                ),
            ),

'may_terminate' => true,
             'child_routes' => array(
                 'default' => array(
                     'type'    => 'Segment',
                     'options' => array(
                         'route'    => '/[:controller[/:action]]',
                     ),
                 ),
             ),
                     ),

    ),
),

'view_manager' => array(
    'template_path_stack' => array(
        'checklist' => __DIR__ . '/../view',
    ),
),
);
我在我的开发服务器上运行这个项目,在我删除了任务并在下面的评论中添加了检查表之后,我得到了一个db连接错误,所以我认为它现在可以工作了

更新:

是的,我得重写一些东西

更新2:

回到原来的样子


url-localhost/MyTaskList/task

<?php
return array(
'controllers' => array(
    'invokables' => array(
        'Checklist\Controller\Task' => 'Checklist\Controller\TaskController',
    ),
),
'router' => array(
    'routes' => array(
        'task' => array(
            'type'    => 'Literal',
            'options' => array(
                'route'    => '/task',
                'defaults' => array(
                    '__NAMESPACE__' => 'Checklist\Controller',
                    'controller'    => 'Task',
                    'action'        => 'index',
                ),
                'constraints' => array(
                    'action' => '^add|edit|delete$',
                    'id'     => '[0-9]+',
                ),
            ),

'may_terminate' => true,
             'child_routes' => array(
                 'default' => array(
                     'type'    => 'Segment',
                     'options' => array(
                         'route'    => '/[:controller[/:action]]',
                     ),
                 ),
             ),
                     ),

    ),
),

'view_manager' => array(
    'template_path_stack' => array(
        'checklist' => __DIR__ . '/../view',
    ),
),
);

我看过你的代码和教程。试试@dixromos98谢谢你的帮助。不幸的是,这与404错误相同:在moduleconfig.php->“may_terminate”=>true,“child_routes”=>array('default'=>array('type'=>'Segment','options'=>array('route'=>'/[:controller[/:操作]]',),),),@dixromos98我真的很感谢你对我的帮助。我更新了我的module.config.php。我希望你是有意让我这样做的。不幸的是,它仍然不起作用。所以现在localhost/MyTaskList/task/index不起作用了。你能告诉我错误吗?我更新了module.config.php(复制和粘贴)并上传到phpcould,但仍然不起作用:上传了你的更新,但它仍然不想知道真相。最后哈哈。我不得不读了一点教程。我很久没有弄乱配置文件了:)。很高兴它起作用了。编码愉快