0
目前我正在學習ZF2。在經歷「Getting started」的過程中,我發現模塊的每個配置文件都充滿了PHP數組。來自文檔的示例:Zend Framework配置文件JSON
<?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主頁上找到它。或者,也許我不應該這樣做?
我建議不要使用JSON。在賽道上的某段時間,您需要在配置文件中爲ServiceManager創建一個單行工廠,然後您需要在php中使用它。 – superdweebie
如果所有''數組(''煩你,並使其看起來很醜,然後使用PHP 5.4的'[]'數組語法。 – superdweebie