将模块名称添加到Zend Skeleton中的application.config.php文件
我是zend框架的新手,我正在尝试配置zend 在这个过程中,我创建了一些相册模块。。按照 1) 我已配置了虚拟主机。。。作为将模块名称添加到Zend Skeleton中的application.config.php文件,php,zend-framework,zend-framework2,Php,Zend Framework,Zend Framework2,我是zend框架的新手,我正在尝试配置zend 在这个过程中,我创建了一些相册模块。。按照 1) 我已配置了虚拟主机。。。作为 <VirtualHost *:80> ServerName zend.localhost DocumentRoot /var/www/Zend_project/public SetEnv APPLICATION_ENV "development" <Directory /var/www/Zend_project/public&g
<VirtualHost *:80>
ServerName zend.localhost
DocumentRoot /var/www/Zend_project/public
SetEnv APPLICATION_ENV "development"
<Directory /var/www/Zend_project/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
我得到的页面如下
2) 获取此页面后,我开始按照《用户指南》创建新模块相册
我遵循用户指南中的每一步。。。并根据用户指南创建文件和文件夹
3) 最后,我在application.config.php文件中添加了相册模块
// This should be an array of module namespaces used in the application.
'modules' => array(
'Application',
'Album', // added as new module
),
将模块相册添加到application.config.php之后
我尝试用上面成功的URL刷新页面
http://zend.localhost/
我得到如下错误消息
Warning: include(/var/www/Zend_project/module/Album/config/module.config.php): failed to open stream: No such file or directory in /var/www/Zend_project/module/Album/Module.php on line 28
Warning: include(): Failed opening '/var/www/Zend_project/module/Album/config/module.config.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/Zend_project/module/Album/Module.php on line 28
Fatal error: Uncaught exception 'Zend\ModuleManager\Listener\Exception\InvalidArgumentException' with message 'Config being merged must be an array, implement the Traversable interface, or be an instance of Zend\Config\Config. boolean given.' in /var/www/Zend_project/vendor/zendframework/zendframework/library/Zend/ModuleManager/Listener/ConfigListener.php:317 Stack trace: #0 /var/www/Zend_project/vendor/zendframework/zendframework/library/Zend/ModuleManager/Listener/ConfigListener.php(127): Zend\ModuleManager\Listener\ConfigListener->addConfig('Album', false) #1 [internal function]: Zend\ModuleManager\Listener\ConfigListener->onLoadModule(Object(Zend\ModuleManager\ModuleEvent)) #2 /var/www/Zend_project/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent)) #3 /var/www/Zend_project/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('loadModule', Object( in /var/www/Zend_project/vendor/zendframework/zendframework/library/Zend/ModuleManager/Listener/ConfigListener.php on line 317
FYI
我使用的是ubuntu 3.10操作系统
我哪里做错了
任何帮助都将不胜感激。我建议您在项目中使用此框架。100%正常工作
可能是权限问题,只需尝试运行以下命令,看看是否有效:
sudo chown -R www-data:www-data /var/www/Zend_project
如果www数据是apache服务器的用户,如果它工作,则apache无权读取或写入您正在使用的项目中的文件/文件夹。此错误意味着zend无法加载Album\config\module.config.php
您的代码在Album\Module.php或Album\config\Module.config.php中出现问题
如果您的代码在Module.php中没有语法错误,并且您的代码
public function getConfig() {
return include __DIR__ . '/config/module.config.php';
}
在这个文件中,module.config.php中出现了错误请显示Album\Module.php和Album\config\Module.config.php,正如“amin arab”所说,它无法加载模块配置,但如果有人在Windows上工作(这是我的情况),我必须返回一个文件夹才能正确加载,因此我更改了以下内容:
public function getConfig() {
return include __DIR__ . '/config/module.config.php';
}
到
在Module.php中
public function getConfig() {
return include __DIR__ . '/config/module.config.php';
}
public function getConfig() {
return include __DIR__ . '/../config/module.config.php';
}