Reputation:
i have installed skeleton application its working well and i have created New module.Module name 'Album'.after create module trying to run the code i am receiving error. here post my code:
module.php
<?php
namespace Album;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
class Module implements AutoloaderProviderInterface, ConfigProviderInterface
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}
?>
module.config.php:
<?php
return array(
'controllers' => array(
'invokables' => array(
'Album\Controller\Album' => 'Album\Controller\AlbumController',
),
),
'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
),
),
);
?>
i am getting error:
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (Album) could not be initialized.' in D:\xampp\htdocs\projects\skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php:195 Stack trace: #0 D:\xampp\htdocs\projects\skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(169): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))
Upvotes: 3
Views: 12804
Reputation: 21
You need disable config caching by default
You can run:
$ composer development-enable
It will work.
Upvotes: 1
Reputation: 1
Check the Case of the filename 'module.php'. On macOS, the filesystem can find module.php and Module.php. But if you deploy to a case sensitive file system (say some variant of Linux eg Centos) you will get this error.
Upvotes: 0
Reputation: 75
This worked for me. Just udpdate autoloading in composer.json:
"autoload": {
"psr-4": {
"Application\\": "module/Application/src/",
"Album\\": "module/Album/src/"
}
},
And then run:
php composer.phar update
Upvotes: 8
Reputation: 69
I had the same problem I resolved it by correct the namesapce of the module The namespace is the name of the folder that contain the module.php, make sure they have the same name
Upvotes: 3