Question

I'm trying to learn zend framework, i started to do this tutorial: getting-started-with-zend-studio

When i finished the tutorial i found out that the route what we have set up in this tutorial namely: http://localhost/MyTaskList/task which should fetch all tasks, actually return with a 404 error (not found).

Any help would be really appreciate.

Here are my files: link

This is the mysql DB script:

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());

UPDATE

This is my 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',
    ),
),
);
Was it helpful?

Solution

url -localhost/MyTaskList/task

i run the project on my development server and after i removed task and added checklist on the comment below and i got a db connection error so i assume it works now.

update:

Yea well i had to rewrite some things!

update 2:

Back to the original.

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',
    ),
),
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top