基于URL的Zf2模块版本控制
问题描述:
I want that when I call myapp's url like http://myapp/v1/admin
and http://myapp/v2/admin
then I want to setup like that module1/Admin
and module2/Admin
so moudlewise versioning can be done.
As I have seen this https://github.com/zfcampus/zf-versioning.Is this applicable for above scenario or please help me out to get right way. Thanks
当我将myapp的URL称为 正如我所见,这个 https:// github.com/zfcampus/zf-versioning.Is 适用于上述情况,或者请帮我解决问题。
谢谢 p>
div> http:// myapp / v1 / admin code时,我希望这样 >和
http:// myapp / v2 / admin code>然后我想设置像
module1 / Admin code>和
module2 / Admin code>那样moudlewise版本控制可以 完成。 p>
答
Define routes in respective module.config.php
files.
module1
'router' => array(
'routes' => array(
'v1_admin' => array(
'type' => 'segment',
'options' => array(
'route' => '/v1/admin[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]*',
),
'defaults' => array(
'controller' => 'Module1\Controller\Admin',
'action' => 'index',
),
),
),
),
),
module2
'router' => array(
'routes' => array(
'v2_admin' => array(
'type' => 'segment',
'options' => array(
'route' => '/v2/admin[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]*',
),
'defaults' => array(
'controller' => 'Module2\Controller\Admin',
'action' => 'index',
),
),
),
),
),