如何在zend框架中显示页面2

时间:2015-12-09 09:04:14

标签: php zend-framework2

我想显示简单的静态页面

我的控制器

class WaitListController extends BaseController
{

    public function indexAction()
    {  
        $viewModel = new ViewModel();
        $Waitlistform = new \Webadmin\Form\WaitListForm();

       // return $viewModel->setVariables(array("customerform"=> $Waitlistform));
        return $viewModel->setVariables(array('userName','mujahed'));
        //return $viewModel;
    }

}

我的页面是表单文件夹中的index.phtml,但它无法正常显示以下错误

/var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/View/Renderer/PhpRenderer.php:498

消息:

Zend\View\Renderer\PhpRenderer::render: Unable to render template "merchant/wait-list/index"; resolver could not resolve to a file

堆栈追踪:

#0 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/View/View.php(205): Zend\View\Renderer\PhpRenderer->render(Object(Zend\View\Model\ViewModel))
#1 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/View/View.php(233): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
#2 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/View/View.php(198): Zend\View\View->renderChildren(Object(Zend\View\Model\ViewModel))
#3 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/Mvc/View/Http/DefaultRenderingStrategy.php(102): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
#4 [internal function]: Zend\Mvc\View\Http\DefaultRenderingStrategy->render(Object(Zend\Mvc\MvcEvent))
#5 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#6 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('render', Object(Zend\Mvc\MvcEvent), Array)
#7 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(352): Zend\EventManager\EventManager->trigger('render', Object(Zend\Mvc\MvcEvent))
#8 /var/www/html/restaurant/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(327): Zend\Mvc\Application->completeRequest(Object(Zend\Mvc\MvcEvent))
#9 /var/www/html/restaurant/public/index.php(46): Zend\Mvc\Application->run()
#10 {main}

1 个答案:

答案 0 :(得分:0)

无法渲染模板 此错误表示您没有为操作创建视图脚本。你有好的文件路径中的index.phtml吗?向我们展示您的文件结构。

骨架应用的良好文件路径:

module/Application/view/application/index/index.phtml

所以对你来说我认为它应该是:

module/YOUR_MODULE_NAME/view/application/wait-list/index.phtml

请记住使用wait-list而不是WaitList。 ZF从驼峰转换路径。

如果您学习ZF2使用骨架应用程序,您将更快地捕获所有内容