ZF 3 error: Module could not be initiated

Here is a Zend framework 3 error that you might get once or twice. It would look something like this;

Fatal error: Uncaught exception ‘Zend\ModuleManager\Exception\RuntimeException’ with message ‘Module (ModuleName) could not be initialized

Here is how to solve it.

  1. Make sure the module is present in project name/config/modules.config.php. For example

return [

…’Application’,

‘ModuleNameOne’,

‘ModuleNameTwo’

];

  1. Check that the module is in the composer.json file. For example
“autoload”:
{
“psr-4”:
{

“Application\\”: “module/Application/src/”,

“ModuleOne\\”: “module/ ModuleOne /src/”

}

},

 

  1. Next run composer update

That solves the problem.

Thanks for your time.

Leave a comment