Zend Framework配置文件JSON


Zend Framework Config file JSON

目前我正在学习ZF2。在学习"入门"时,我发现模块的每个配置文件都充满了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',
        ),
    ),
);

数组中有数组,有数组。事实上,我知道,数组只是函数的名称,它更像是带有键/值对的映射。

Zend的一个MODS指出,我们可以将JSON用于配置文件:http://framework.zend.com/manual/2.0/en/user-guide/routing-and-controllers.html#comment-696979913

有人能为初学者提供榜样吗?我真的更喜欢使用JSON格式来配置这些文件,而不是数组/映射,但我在ZF主页上找不到它。或者也许我不该这么做?

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

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