2015-10-19 57 views
0

我已经通过其他类似的问题在这里尝试了很多事情,但无济于事。ZF2解析器无法解析为文件(但适用于开发环境)

我有一个仪表盘控制器正常工作我的开发机上,虽然当它被上传到它报告的生产服务器:

的Zend \查看\渲染器\ PhpRenderer ::渲染:无法呈现模板“仪表盘\仪表板\目录”;解析器无法解析到一个文件

我检查了我的module.config.php文件的视图模板(和它的上有正确列出)

'template_path_stack' => array(
    'dashboard' => __DIR__ . '/../view', 
), 

和文件也是在那个物理位置。 ..

我不知道我在这方面缺少什么,所以任何指针会很好。

UPDATE:

这里是控制器的代码:

public function indexAction() { 
     //check the users authenticity 
     $userId = null; 
     $auth = $this->getServiceLocator()->get('zfcuser_auth_service'); 

     if ($auth->hasIdentity()) { 
      $user = $auth->getIdentity(); 
      $userId = $user->getId(); 
     } else { 
      $this->redirect()->toUrl('/user/login'); 
     } 

     //set the view model to improve performance 
     //http://samminds.com/2012/11/zf2-performance-quicktipp-1-viewmodels/ 
     $viewModel = new ViewModel(); 
     $viewModel->setTemplate('Dashboard\Dashboard\Index'); 

     //return the amount of counts the various items have outstanding  
     $dbAdapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter'); 
     $systemRepo = $this->getSystemRepo($dbAdapter); 

     $internalContacts = $systemRepo->widgetAlphabetList("Internal Contacts", $systemRepo->getInternalContacts(), 'firstname', 'surname'); 

     return $viewModel->setVariables(array(
        'internalContacts' => $internalContacts 
     )); 
    } 

而完整路径文件(添加index.phtml上的下方的端部):

/var/www/html/module/Dashboard/view/dashboard/dashboard

+0

尝试替换'__DIR__。 '/../ view''使用dirname(__ DIR__)。 '/ view'' – Yang

+0

请在您的控制器中显示代码(您设置视图的位置)。 – Wilt

+0

什么是文件的完整路径? –

回答

0

我打算猜测dev机器不是大小写敏感的文件系统,并且prod区分大小写。试试这个:

$viewModel->setTemplate('dashboard/dashboard/index') 
+0

你好,我尝试过,但它也没有工作,虽然它看起来更美观,所以我将他们所有的模板调用改为小写(以防万一) – mailman1979