Rob Rob - 4 months ago 67
PHP Question

Zend Skeleton Application album tutorial 404

As far as I can see I've followed the Zend skeleton application tutorial to the letter (I actually went through it twice with the same result) but when I try to access

zf2-tutorial.localhost/album
I get the following error:

A 404 error occurred
Page not found.
The requested URL could not be matched by routing.

No Exception available
© 2005 - 2015 by Zend Technologies Ltd. All rights reserved.


Going to
zf2-tutorial.localhost
displays the Zend welcome page and the 404 is wrapped in the Zend styling so something at least appears to be working.

I have tried the offered solutions on similar questions here and here but to no avail, any ideas would be appreciated. Thanks.

Edit: I am using running the tutorial locally on XAMPP.

Rob Rob
Answer

It turns out in module.config.php I had split the array with the controllers and router into two arrays by mistake. Combining them into one seems to have solved this particular issue.

Code follows:

 return array(
 'controllers' => array(
     'invokables' => array(
         'Album\Controller\Album' => 'Album\Controller\AlbumController',
        ),
    ),

  'router' => array(
         'routes' => array(
             'album' => array(
                 'type'    => 'segment',
                 'options' => array(
                     'route'    => '/album[/:action][/:id]',
                     'constraints' => array(
                         'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                         'id'     => '[0-9]+',
                     ),
                     'defaults' => array(
                         'controller' => 'Album\Controller\Album',
                         'action'     => 'index',
                     ),
                 ),
             ),
         ),
     ), 
);