Zf 3 starter by following official tutorial



Hi, i’m getting start with zend framework version 3.0.3-dev, I followed thise tutoriel https://docs.zendframework.com/tutorials/getting-started/overview/, everything is gonna wel unti i tried to call album page it retun thise error.

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

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

are there somone who can help me.
thise is zf-tuto/public/index.php fil


use Zend\Mvc\Application;
use Zend\Stdlib\ArrayUtils;

 * This makes our life easier when dealing with paths. Everything is relative
 * to the application root now.

// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server') {
    $path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
    if (__FILE__ !== $path && is_file($path)) {
        return false;

// Composer autoloading
include __DIR__ . '/../vendor/autoload.php';

if (! class_exists(Application::class)) {
    throw new RuntimeException(
        "Unable to load application.\n"
        . "- Type `composer install` if you are developing locally.\n"
        . "- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.\n"
        . "- Type `docker-compose run zf composer install` if you are using Docker.\n"

// Retrieve configuration
$appConfig = require __DIR__ . '/../config/application.config.php';
if (file_exists(__DIR__ . '/../config/development.config.php')) {
    $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php');

// Run the application!


   namespace Album;

   //use Zend\ServiceManager\Factory\InvokableFactory;

   return [
       /*'controllers' => [
           'factories' => [
               Controller\AlbumController::class => InvokableFactory::class,
       // The following section is new and should be added to your file:
    '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',

       'view_manager' => [
           'template_path_stack' => [
               'album' => __DIR__ . '/../view',


   namespace Album;
   //use Album\Model\Album;
   //use Album\Model\AlbumTable;
   use Zend\Db\Adapter\Adapter;
   use Zend\Db\ResultSet\ResultSet;
   use Zend\Db\TableGateway\TableGateway;
   use Zend\ModuleManager\Feature\ConfigProviderInterface;
   class Module implements ConfigProviderInterface
      // getConfig() method:
       public function getConfig()
           return include __DIR__ . '/../config/module.config.php';
        // getServiceConfig method:
       public function getServiceConfig()
           return [
               'factories' => [
                   Model\AlbumTable::class => function($container) {
                       $tableGateway = $container->get(Model\AlbumTableGateway::class);
                       return new Model\AlbumTable($tableGateway);
                   Model\AlbumTableGateway::class => function ($container) {
                       $dbAdapter = $container->get(AdapterInterface::class);
                       $resultSetPrototype = new ResultSet();
                       $resultSetPrototype->setArrayObjectPrototype(new Model\Album());
                       return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
       // getControllerConfig method:
       public function getControllerConfig()
           return [
               'factories' => [
                   Controller\AlbumController::class => function($container) {
                       return new Controller\AlbumController(



 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License

 * List of enabled modules for this application.
 * This should be an array of module namespaces used in the application.
return [


   namespace Album\Controller;
   use Album\Model\AlbumTable;
   use Zend\Mvc\Controller\AbstractActionController;
   use Zend\View\Model\ViewModel;

   class AlbumController extends AbstractActionController
      // Add this property:
       private $table;

       // Add this constructor:
       public function __construct(AlbumTable $table)
           $this->table = $table;

       public function indexAction()
            return new ViewModel([
               'albums' => $this->table->fetchAll(),

       public function addAction()

       public function editAction()

       public function deleteAction()


// module/Album/view/album/album/index.phtml:

$title = 'My albums';
<h1><?= $this->escapeHtml($title) ?></h1>
    <a href="<?= $this->url('album', ['action' => 'add']) ?>">Add new album</a>

<table class="table">
<?php foreach ($albums as $album) : ?>
        <td><?= $this->escapeHtml($album->title) ?></td>
        <td><?= $this->escapeHtml($album->artist) ?></td>
            <a href="<?= $this->url('album', ['action' => 'edit', 'id' => $album->id]) ?>">Edit</a>
            <a href="<?= $this->url('album', ['action' => 'delete', 'id' => $album->id]) ?>">Delete</a>
<?php endforeach; ?>

So i want your help please!


i think you should add some proper tags on this issue, so other people can see it.


I’ve categorized this post under “Questions: Components” and added the tag “zend-mvc” now.

Just as an FYI: you cannot create tags until you’re at trust level 3 (which means you’ve created a minimum number of posts and provided useful conversations). However, if tags already exist, you should be able to add them to any post you write.


I’ve re-formatted your question to add code sections around all code and templates; this allows them to be syntax highlighted.

For information on how to format posts, please see https://superuser.com/editing-help (as the Markdown used in Discourse is the same as for StackOverflow).


What URL were you attempting to reach when you got the 404 error you illustrated, @karango?


I have the similar problem. I used the official tutorial: https://docs.zendframework.com/tutorials/getting-started/database-and-models/ and now I get similar error.
I have just changed the name from “Album” into “Group”.

I get the error:

The requested controller could not be mapped to an existing controller class.

Testapp\Controller\GroupController (resolves to invalid controller class or alias: Testapp\Controller\GroupController)

I mean, how the methods “getControllerConfig” and “getServiceConfig” should be called, if they are just defined within the “Module” class, that implements only “ConfigProviderInterface” - where only the “getConfig” method are defined?

I hope, somebody can tell me what is wrong :confused:


Me too, this post is quite long time. I cannot proceed with the tutorial.


@karango never answered the question:

What URL were you attempting to reach when you got the 404 error you illustrated

Do you have the same problem as described in the first post? (404 error)