0
我在module.config.php
文件的路線是這樣的:如何在ZF2 ..中使用控制檯路由中的約束?
'console' => array(
'router' => array(
'routes' => array(
'updatecron' => array(
'options' => array(
'route' => 'cronupdate',
'defaults' => array(
'controller' => 'Application\Controller\Cron',
'action' => 'update'
)
)
)
)
)
)
現在我需要一個動態值傳遞給這個動作像我們這樣做,我們使用的限制像低於正常路線:
'route' => 'cronupdate[/:id][/]',
'constraints' => array(
'id' => '[0-9]+',
),
但它不工作,並拋出錯誤。雖然谷歌搜索我在ZF2 github issues這樣找到了一種方法某處:
'console' => array(
'router' => array(
'routes' => array(
'updatecron' => array(
'options' => array(
'route' => 'cronupdate <id>',
'constraints' => array(
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Application\Controller\Cron',
'action' => 'update'
)
)
)
)
)
)
但也不能正常工作。請建議我如何才能做到這一點。
注意: - 我需要通過exec函數調用它,這就是爲什麼使用控制檯路由。
這是編寫id的方法:''route'=>'cronupdate [/:id]',' – Unex
您寫了*「雖然使用Google搜索我在ZF2的某個地方找到了方法」* ...您在哪裏找到這個?添加一個參考將是很好的。我很難想象官方文檔會提供這種路由。路由ID應定義像@Unex寫... – Wilt
@Wilt我沒有在我的問題中提到,我發現在官方文檔中的東西,請檢查此鏈接,用戶確認其在許多情況下爲他工作https: //github.com/zendframework/zf2/issues/6316 – Ritesh