phpzend-framework3laminas

I am following Laminas MVC tutorial, Routs I created return 404 error instead of the relevant view


I'm following the laminas MVC tutorial on official website. I have followed all the steps as said. but my Album routes return 404 error. I made the autoload entry and ran composer dump-autoload command as well. paths that gives 404 are.

http://lamin.test/album
http://lamin.test/album/index
http://lamin.test/album/add
http://lamin.test/album/edit
http://lamin.test/album/delete

following are my configuration files.

config/modules.config.php

<?php

return [
    'Laminas\Form',
    'Laminas\I18n',
    'Laminas\InputFilter',
    'Laminas\Filter',
    'Laminas\Hydrator',
    'Laminas\Db',
    'Laminas\Router',
    'Laminas\Validator',
    'Application',
    'Album',
];

module/Album/config/module.config.php

namespace Album;

use Album\Controller\AlbumController;
use Laminas\Router\Http\Segment;
use Laminas\ServiceManager\Factory\InvokableFactory;

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' => AlbumController::class,
                        'action' => 'index',
                    ],
                ],
            ],
        ],
    ],
    'controllers' => [
        'factories' => [
            AlbumController::class => InvokableFactory::class,
        ],
    ],
    'view_manager' => [
        'template_path_stack' => [
             __DIR__ . '/../view',
        ],
    ],
];

module/src/module.php

<?php
namespace Album;

use Album\Controller\AlbumController;
use Laminas\ModuleManager\Feature\ConfigProviderInterface;

class Module implements ConfigProviderInterface
{
    public function getConfig() : array
    {
        return include __DIR__.'/../config/module.config.php';
    }
}

module/Album/src/Controller/AlbumController.php

<?php


namespace Album\Controller;

use Laminas\View\Model\ViewModel;
use Laminas\Mvc\Controller\AbstractActionController;


class AlbumController extends AbstractActionController
{
    public function indexAction()
    {
        return new ViewModel();
    }

    public function addAction()
    {
        return new ViewModel();
    }

    public function editAction()
    {
        return new ViewModel();
    }

    public function deleteAction()
    {
        return new ViewModel();
    }
}

the view paths are as follows

 module
  |-Album
    |-view
     |-album
      |-album
       |index.phtml
       |add.phtml
       |edit.phtml
       |delete.phtml

I am running Homestead setup on vagrant VM. Application module paths works fine only my Album module paths returns the 404 error page.


Solution

  • as @Ermenegildo suggested I've turned config/application.config.php 'config_cache_enabled' => false, and it worked.