ZF3 - Tutorial problem - Module (Album) could not be initial

For programming and general questions on Zend Framework

ZF3 - Tutorial problem - Module (Album) could not be initial

Postby s7043 on Thu Sep 15, 2016 12:03 pm

I tried to follow the tutorial, but I get the following error:

Code: Select all
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (Album) could not be initialized.' in /var/www/html/skeleton-application/vendor/zendframework/zend-modulemanager/src/ModuleManager.php:203 Stack trace: #0 /var/www/html/skeleton-application/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(175): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent)) #1 /var/www/html/skeleton-application/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(97): Zend\ModuleManager\ModuleManager->loadModule('Album') #2 /var/www/html/skeleton-application/vendor/zendframework/zend-eventmanager/src/EventManager.php(271): Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent)) #3 /var/www/html/skeleton-application/vendor/zendframework/zend-eventmanager/src/EventManager.php(143): Zend\EventManager\EventManager->triggerListeners(Object(Zend\ModuleManager\ModuleEvent)) #4 /var/www/html/skeleton-application/vendo in /var/www/html/skeleton-application/vendor/zendframework/zend-modulemanager/src/ModuleManager.php on line 203


If I comment, in config/modules.config.php, the 'Album' entry, the homepage is displayed properly.
s7043
 
Posts: 1
Joined: Thu Sep 15, 2016 11:59 am

Re: ZF3 - Tutorial problem - Module (Album) could not be ini

Postby matt2674 on Sat Sep 24, 2016 11:35 pm

Hey, I am just beginning with ZF3 so I'm not sure what could be the problem from just the stack trace. There are just too many things that can go wrong in a module.

You could push your tutorial code to a public Git repository like Github and then link it here. That will make it easier to help you.
matt2674
 
Posts: 2
Joined: Sat Sep 24, 2016 11:27 pm

Re: ZF3 - Tutorial problem - Module (Album) could not be ini

Postby j9744 on Sat Nov 05, 2016 2:00 pm

There is a Bug in the Tutorial.

The Module.php has to be in module/Album not module/Album/src

An other one is in module.config.php you have to add:

use Zend\ServiceManager\Factory\InvokableFactory;
use Zend\Router\Http\Segment; //<-- Add this call

return [
j9744
 
Posts: 1
Joined: Sat Nov 05, 2016 1:57 pm

Re: ZF3 - Tutorial problem - Module (Album) could not be ini

Postby mham3595 on Fri Feb 24, 2017 1:08 am

for resolve this probleme goto tutorial:
docs zendframework com/tutorials/getting-started/forms-and-actions
in part:
###############################################
Ensuring that the home page displays the list of albums
###############################################
This is due to a route set up in the Application module's module.config.php.
To change it, open module/Application/config/module.config.php and find the home route:
Code: Select all
<?php
namespace Application;

use Zend\Router\Http\Literal;
use Zend\Router\Http\Segment;
use Zend\ServiceManager\Factory\InvokableFactory;
use Album\Controller\AlbumController;  <---- important

return [
    'router' => [
        'routes' => [
            'home' => [
                'type' => Literal::class,
                'options' => [
                    'route'    => '/',
                    'defaults' => [
                        'controller' => Controller\IndexController::class, <---- remplace this line
                        'controller' => AlbumController::class,  <------- by this line
                        'action'     => 'index',
                    ],
                ],
            ],
          /* ------- */ 
        ],

thank to Zend Framework team's
mham3595
 
Posts: 1
Joined: Fri Feb 24, 2017 12:52 am

Re: ZF3 - Tutorial problem - Module (Album) could not be ini

Postby musa7349 on Tue Aug 22, 2017 1:00 am

Had the same problem. All I did to resolve it was to run the following Composer commands:

composer init
composer install
composer self-update.

Am quite sure it has to do with the modules not been able to load.
Try the last two. It should resolve the issue.
Am just new to PHP and Zend.
musa7349
 
Posts: 3
Joined: Sun Aug 20, 2017 7:17 am

Re: ZF3 - Tutorial problem - Module (Album) could not be ini

Postby musa7349 on Tue Aug 22, 2017 1:37 am

Please in addition, don't forget to run

composer dump.

Hope this helps.
musa7349
 
Posts: 3
Joined: Sun Aug 20, 2017 7:17 am


Return to Zend Framework

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron