我从 ZF2 迁移到 ZF3。现在我有一个问题。我的视图脚本在正确的位置,配置似乎没问题,但我收到以下错误:
Zend\View\Renderer\PhpRenderer::render: 无法渲染模板“party/controllers/write-party/add”;解析器无法解析到文件
这是一个相当常见的要解决的错误,但问题是由于某种原因,我controllers
在模板路径中获取了文件夹。模板路径应该是parties/write-party/add
.
模块.config.php
return [
'controllers' => [
'factories' => [
WritePartyController::class => WritePartyControllerFactory::class,
],
],
'router' => [
'routes' => [
'parties' => [
'type' => Literal::class,
'options' => [
'route' => '/parties',
'defaults' => [
'__NAMESPACE__' => 'Parties\Controllers',
'controller' => 'Index',
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'add' => [
'type' => Segment::class,
'options' => [
'route' => '/add',
'defaults' => [
'controller' => WritePartyController::class,
'action' => 'add',
],
],
],
//...
'view_manager' => [
'template_path_stack' => [
'parties' => __DIR__ . '/../view',
],
'strategies' => [
'ViewJsonStrategy',
],
],
],
如何获得我的视图脚本的正确路径是parties/write-party/add
?