我從https://github.com/zendframework/ZendSkeletonApplication下載了骷髏,它工作正常。一切都很清楚。如何路由到許多模塊?
但是當我添加另一個模塊會發生什麼?我複製模塊從骨架,我改了個名字,然後加入我的新模塊application.config.php:
return array(
'modules' => array(
'Application',
'Api',
),
[...]
,並更改module.config.php路線:
return array(
'router' => array(
'routes' => array(
'api' => array(
'type' => 'Literal',
'options' => array(
'route' => 'api/',
'defaults' => array(
'__NAMESPACE__' => 'Api\Controller',
'controller' => 'Api',
'action' => 'api',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/api[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
'service_manager' => array(
'factories' => array(
'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
),
),
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController',
'Application\Controller\Auth' => 'Application\Controller\AuthController'
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
);
但現在我明白了從api甚至從骨架位置的佈局。怎麼做?
模塊是_NOT_獨立的容器。他們是交叉關注的問題,而不是你的應用程序的子部分。 – Ocramius 2013-02-27 20:09:47