RuntimeException: Module could not be initialized in ModuleManager

When adding a new module manually in Zend 3 platform, you basically add files within a defined folder structure of your own (you can just copy a skeleton application and rename the directory). See the tutorial on Zend 3 project for more details.

Once you have added the files you will generally meet a few errors if you just hit the refresh button of your browser.

PHP Fatal error: Uncaught Zend\ModuleManager\Exception\RuntimeException: Module could not be initialized in … ModuleManager

So make sure you do the following steps

Inside the config directory of your project :


return

[ 'Zend\Router',
'Zend\Validator',
'Zend\Session',
'Zend\Cache',
'Zend\Paginator',
'Zend\I18n',
'Zend\InputFilter',
'Zend\Filter', 
'Zend\Hydrator', 
'Zend\Mvc\Plugin\Prg', 
'Zend\Mvc\Plugin\Identity', 
'Zend\Mvc\Plugin\FlashMessenger', 
'Zend\Mvc\Plugin\FilePrg', 
'Zend\Form', 
// Add the Doctrine integration modules. 
'DoctrineModule', 
'DoctrineORMModule', 
'DoctrineDataFixtureModule', 
'Application', 
'MyModule' ]; 

And to make sure everything is running fine on the configuration side, add this at the root of your project inside composer.json file :


"autoload" : {

"autoload" :

{ "psr-4" :

{

"Application\\" : "module/Application/src/",

"MyModule\\" : "module/MyModule/src/"

}

},

 

Beware when using an IDE such as Eclipse or NetBeans or any others, when you change the composer.json file using the default editor, it might not overwrite the true file and you will end up with the Runtime Exception. So do modify your file content using a text editor :

Text Editor - composer json

Run composer update

One more last step and you will be done :

$ composer update

 

If you are having other issues, you should check the right paths which you have set up in your module.config.php file.

Stay tune for more typical Zf3 integration errors, we will add them here so we can keep track on them and have a quick fix when we encounter them again. For instance we will try to add this entry right inside our code in another project.

 

Leave a Reply

Want more information?

Related links will be displayed here in this section for you to pick up another good spot to get more details about Web marketing and Search Engine Optimization. There will be some sites which we selected to ease the work of any webmaster or/and web marketer on the Internet.

%d bloggers like this: