我从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