本文介绍了未捕获的异常 'Zend\ModuleManager\Exception\RuntimeException' 带有消息 'Module (Album) 无法初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经安装了框架应用程序,它运行良好,我创建了新模块.模块名称为相册".创建模块后尝试运行代码我收到错误.在这里发布我的代码:
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:
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',
),
),
);
?>
我收到错误:
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))
推荐答案
这对我有用.只需在 composer.json 中自动加载 udpdate:
This worked for me.Just udpdate autoloading in composer.json:
"autoload": {
"psr-4": {
"Application\\": "module/Application/src/",
"Album\\": "module/Album/src/"
}
},
然后运行:
php composer.phar update
这篇关于未捕获的异常 'Zend\ModuleManager\Exception\RuntimeException' 带有消息 'Module (Album) 无法初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!