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...