2

I try to follow Akrabats Tutorial the Application/Index is working, the Album part not.

I tried it also with the ZendSkeletonModule with no luck.

The error in both cases is:

album/album (resolves to invalid controller class or alias: album/album)

I tried it with ZF2 master and beta4 tag (but beta4 tag gives php error about missing method getEventManager)

I took the code from Akrabats Tutorial, and after that failed used the code form the GitHub Repo. Unfortunatly there isnt some Forum or Comment section to ask for help.

I found some diffrences in the tutorial and the Skeleton (zfcUser has the same diffrence) in the module.config.php (which i believe is the core of the problem).

The tutorial uses classes in the controller index, zfcUser and the Skeleton using invokables but it doesnt seem to matter, as the error dont change.

my module.config currently looks like this:

<?php

return array(

    // Controllers in this module
    'controller' => array(
        'invokables' => array(
            'album/album' => 'Album\Controller\AlbumController',
        ),        
    ),


    // Routes for this module
    'router' => array(
        'routes' => array(
            'album' => array(
                'type' => 'Literal',
                'priority' => 1000,
                'options' => array(
                    'route' => '/album',
                    'defaults' => array(
                        'controller' => 'album/album',
                        'action' => 'index',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array( 
                    'misc' => 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/album',
                                'action'     => 'index',
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),    

    // View setup for this module
    'view_manager' => array(
        'template_path_stack' => array(
            'album' => __DIR__ . '/../view',
        ),
    ),
);

Album\Controller\AlbumController:

<?php

namespace Album\Controller;

use Zend\Mvc\Controller\ActionController,
    Zend\View\Model\ViewModel,
    Album\Model\AlbumTable,
    Album\Model\Album,
    Album\Form\AlbumForm;

class AlbumController extends ActionController
{
// [....]
}

I dont know where to look to fix this error, does someone of you have an idea?

Code is like orginal on github (see links above) when not mentioned otherwise.

TIA

vascowhite
  • 18,120
  • 9
  • 61
  • 77
Rufinus
  • 29,200
  • 6
  • 68
  • 84

4 Answers4

7

The difference here is not only the invokables, but also that the array key is now "controllers" in plural, wich did the trick for me. In your code "invokables" is already changed, but you seem to use "controller" as key.

    'controllers' => array(
            'invokables' => array(
                    'album/album' => 'Album\Controller\AlbumController',
            ),
    ),
sirkohli
  • 86
  • 1
4

Apparently there is a change in the array for the controller. Now the classes key is changed to invokables: At the module.config.php

    'controller' => array(
            'classes' => array(
                    'album/album' => 'Album\Controller\AlbumController',
            ),
    ),

has to be changed to

    'controllers' => array(
            'invokables' => array(
                    'album/album' => 'Album\Controller\AlbumController',
            ),
    ),
Al-Punk
  • 3,531
  • 6
  • 38
  • 56
  • Hello Rufinus, I had not noticed that in your code. The change solved the problem for me anyway. – Al-Punk Jul 06 '12 at 11:09
  • +Armand i missed your change to "controller" as +sirkohli mentioned. i gave him the right answer flag, couse he is a new member. thanks for your help anyway. – Rufinus Jul 08 '12 at 08:36
3

Found it, it The ActionController class seems to be gone on ZF2-beta4 so your AlbumController needs to be this way:

use Zend\Mvc\Controller\AbstractActionController,
    Zend\View\Model\ViewModel;

class AlbumController extends AbstractActionController {
   .....
}
AlexWS
  • 76
  • 3
  • hi and welcome to SO. your are right, (intresting enough it doesnt throw an error with ActionController) but the routing problem isnt fix by it. – Rufinus Jul 06 '12 at 05:24
  • Same problem, changed to AbstractActionController and still have problems with the routing. – Al-Punk Jul 06 '12 at 10:27
  • As Armand Says you need to change the module.config.php to invokables – AlexWS Jul 06 '12 at 15:47
0

You must right config/application.config.php

<?php
return array(
    'modules' => array(
        'Application',
        'Album',
    ),
    'module_listener_options' => array(
        'config_glob_paths'    => array(
            'config/autoload/{,*.}{global,local}.php',
        ),
        'module_paths' => array(
            './module',
            './vendor',
        ),
    ),
);
neoerol
  • 911
  • 1
  • 12
  • 18