I'm getting a Laminas generated 404 error. Can anyone help?

The error is as follows:

A 404 error occurred

Page not found.

The requested URL could not be matched by routing.

No Exception available

I’ve registered the module and namespace with composer. The requested url is http://laminas.com/index. I’m using XAMPP on Window 10. My code is as follows:

module\Album\config\module.config.php

<?php

declare(strict_types=1);

namespace Album;

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

module\Album\src\Module.php

<?php

declare(strict_types=1);

namespace Album;

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

module\Album\src\Controller\AlbumController.php

<?php

declare(strict_types=1);

namespace Album\Controller;

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

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

module\Album\view\album\album\index.phtml

Index page displays here...

My mistake I figured this out.

1 Like

Can you please share the solution. I am also facing the same error

This is a very interesting question indeed. You(@Farsideman) were able to redirect Laminas.com to your laptop or desktop? For anyone who can’t see any error or exception in Lamins MVC application, he/she should check if display_error is on in his/her Apache configuration. If that is the case then he/she should check the application config file display_exception configuration. If it is false then Laminas will not show any exception detail.

Secondly, the route which is mentioned here has nothing to do with the Album route, because according to the default configuration of the Laminas MVC, the index route is mapped to the application index controller index action. I hope it helps. Thanks!