我添加了一个名为Album
的模块。这是我的代码:
<AppName>/module/Album/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';
}
}
<AppName>/module/Album/config/module.config.php
<?php
return array(
'controllers' => array(
'invokables' => array(
'Album\Controller\Album' => 'Album\Controller\AlbumController',
),
),
'router' => array(
'routes' => array(
'album' => array(
'type' => 'segment',
'options' => array(
'route' => '/album[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]*',
),
'defaults' => array(
'controller' => 'Album\Controller\Album',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
),
),
);
这是我的controller
:
<?php
namespace Album\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class AlbumController extends AbstractActionController
{
public function indexAction()
{
}
public function addAction()
{
}
public function editAction()
{
}
public function deleteAction()
{
}
}
然后我将模块名称添加到config/application/config.php
。然后我刷新本地服务器,我收到以下错误和警告:
Warning: include(/var/www/html/trialone/module/Album/config/module.config.php): failed to open stream: No such file or directory in /var/www/html/trialone/module/Album/Module.php on line 28
Warning: include(): Failed opening '/var/www/html/trialone/module/Album/config/module.config.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/trialone/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/html/trialone/vendor/zendframework/zendframework/library/Zend/ModuleManager/Listener/ConfigListener.php on line 342
Zend\ModuleManager\Listener\Exception\InvalidArgumentException: Config being merged must be an array, implement the Traversable interface, or be an instance of Zend\Config\Config. boolean given. in /var/www/html/trialone/vendor/zendframework/zendframework/library/Zend/ModuleManager/Listener/ConfigListener.php on line 342
我该如何解决呢?
应用结构: