0

我已经使用 Laminas MVC Skeleton Application 设置了一个基本应用程序。

我创建了一个具有以下结构的模块测试:

Test
|- config
|  |- module.config.php
|- src
|  |- Controller
|  |  |- IndexController.php
|  |- Form
|  |- Model
|  |- Module.php
|- view
   |- test
   |  |- index
   |  |  |- index.phtml

索引控制器.php

<?php

namespace Test\Controller;

use Laminas\Mvc\Controller\AbstractActionController;

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
    }
}

view_manager 配置:

'view_manager' => [
    'template_path_stack' => [
        __DIR__ . '../view',
    ],
],

但我收到以下错误

Laminas\View\Renderer\PhpRenderer::render: Unable to render template "test/index/index"; resolver could not resolve to a file

我希望它在 /view/test/index 中搜索 index.phtml 模板,但找不到它。

如何解决这个问题?

4

1 回答 1

0

尝试重命名“view/test/test”中的子文件夹“view/test/index”

|- view
   |- test
   |  |- test
   |  |  |- index.phtml

然后以这种方式更改配置:

'view_manager' => [
    'template_path_stack' => [
         'test' => __DIR__ . '/../view',
    ],
],
于 2021-04-19T10:21:11.243 回答