1
我已經在module.config中創建了一個名爲'currency'的新模塊並配置了路由。它工作正常。 之後,我添加了一個名爲CrateController的新貨幣匯率控制器。並且還創建了窗體,模型和視圖文件。 但它路由不正確。無法呈現模板zf2
錯誤:
Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render template "currency/crate/index"; resolver could not resolve to a file....
任何線索檢查了這一點會有所幫助。
我的module.config文件如下。
return array(
'controllers' => array(
'invokables' => array(
'Currency\Controller\Currency' => 'Currency\Controller\CurrencyController',
'Currency\Controller\Crate' => 'Currency\Controller\CrateController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'currency' => array(
'type' => 'segment',
'options' => array(
'route' => '/currency[/:action][/:currency_id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'currency_id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Currency\Controller\Currency',
'action' => 'index',
),
),
),
'crate' => array(
'type' => 'segment',
'options' => array(
'route' => '/crate[/:action][/:c_rate_id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'c_rate_id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Currency\Controller\Crate',
'action' => 'index',
),
),
),
),
),
Oops..First事情失敗。我沒有在Crate文件夾下創建index.phtml文件。第二件事是好的。現在它正在工作。謝謝你的幫助 – cha