【问题标题】:rendering layout on the production server在生产服务器上渲染布局
【发布时间】:2017-07-12 15:58:14
【问题描述】:

我的生产服务器无法呈现我的登录布局。在我的开发系统上一切正常。

这里是生产网站上的错误:

致命错误:未捕获 Zend\View\Exception\RuntimeException: Zend\View\Renderer\PhpRenderer::render: Unable to render template "layout/layoutlogin"

我是怎么做到的:

我的Application/config/module.config.php 给出的模板如下:

'view_manager' => [
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => [
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
            'layout/layoutlogin'      => __DIR__ . '/../view/layout/layoutlogin.phtml',
            'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
            'error/404'               => __DIR__ . '/../view/error/404.phtml',
            'error/index'             => __DIR__ . '/../view/error/index.phtml',
        ],
        'template_path_stack' => [
            __DIR__ . '/../view',
        ],
    ],

在我的 Indexcontroller 中,我将布局设置为:

$this->layout()->setTemplate('layout/layoutlogin');

这可能会做我想要的!?在开发环境的开发模式下,我没有收到任何错误和警告。任何想法表示赞赏!

【问题讨论】:

    标签: zend-framework zend-framework3 zend-layout


    【解决方案1】:

    你可以试试这个方法

    public function loginAction()
    {
        // Provide the layout here
        $this->layout('layout/layoutlogin');
    
        $view = new ViewModel();
    
        // Here you may set the template
        $view->setTemplate("/module/controller/template");
    
        return $view;
    } 
    

    这实际上意味着您正在使用非默认布局,然后在此布局内您可以使用您想要的模板。

    【讨论】:

    • 这是什么原因,它在开发系统上本地工作,但在生产系统上却不行?我什至停用了每个 $this->layout 东西,它根本不起作用
    • 我不确定您的代码背后发生了什么。我有一些问题要问你!你的php版本是多少?您是否禁用了开发环境?如果不通过作曲家使用这个composer development-disable。您使用的是什么 php 打开标签? “
    • 它解决了,就像我猜它是服务器问题一样
    • 太棒了!你做到了! :)
    【解决方案2】:

    错误已解决。实际上这是一个服务器配置问题。在这种情况下,是 Apache 没有足够的文件夹权限

    数据/缓存

    【讨论】:

    • 那么,它已经修复了吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-28
    • 2020-10-22
    • 1970-01-01
    • 1970-01-01
    • 2019-10-05
    • 2012-04-27
    相关资源
    最近更新 更多