Zend Framework 2 でセグメント ルートのセグメント子ルートを作成するのに少し問題があります。ドキュメントから取得しようとしましたが、少し混乱します。誰でも私を助けることができると思いました。
これは基本的に私が定義したいルートです:
root/monitor/customer/12424/job/1243
12424 は顧客 ID、1243 はジョブ ID です。仕事の部分も別のアクションになる可能性があります。
以下は、私がルーティングでやろうとしたことです。私はいくつかの失敗したアプローチを試みましたが、これは私が現在持っているものです。仕事がうまくいくまでのすべて。
'router' => array(
'routes' => array(
'monitor' => array(
'type' => 'segment',
'options' => array(
'route' => '/monitor[/][:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Monitor\Controller\Monitor',
'action' => 'index',
),
),
'child_routes' => array(
'customer' => array(
'type' => 'segment',
'options' => array(
'route' => '/customer/:id[/][/:action/:jobid]',
'defaults' => array(
'action' => 'customer'
)
),
),
),
),
),
),
次の 404 エラーが発生します。
The requested URL could not be matched by routing.