Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Zend框架配置文件JSON_Php_Json_Zend Framework2 - Fatal编程技术网

Php Zend框架配置文件JSON

Php Zend框架配置文件JSON,php,json,zend-framework2,Php,Json,Zend Framework2,目前我正在学习ZF2。在浏览“Getting start”时,我看到模块的每个配置文件都充满了PHP数组。文档中的一个示例: <?php return array( 'controllers' => array( 'invokables' => array( 'Album\Controller\Album' => 'Album\Controller\AlbumController', ), ),

目前我正在学习ZF2。在浏览“Getting start”时,我看到模块的每个配置文件都充满了PHP数组。文档中的一个示例:

<?php
return array(
    'controllers' => array(
        'invokables' => array(
            'Album\Controller\Album' => 'Album\Controller\AlbumController',
        ),
    ),

    // The following section is new and should be added to your file
    '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',
        ),
    ),
);

我会尝试修改
Module.php
文件中的
getConfig()
函数:

return \Zend\Config\Factory::fromFile(__DIR__ . '/config/module.config.json', false);

我建议不要使用JSON。过一段时间,您会希望在配置文件中为ServiceManager创建一个单行工厂,然后在php中需要它。如果所有
数组(
)都让您恼火并使其看起来很难看,那么请使用PHP5.4的
[]
数组语法。