Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony2,包含文件错误_Php_Symfony - Fatal编程技术网

Php Symfony2,包含文件错误

Php Symfony2,包含文件错误,php,symfony,Php,Symfony,我有个奇怪的问题。我有两个php页面:Index.html.php和Header.php只包含在Symfony2项目上运行的html代码。索引页面包含一个非常普通的include:include“Header.php”。问题是,当我第一次加载索引时,页面正常呈现,所有内容都已就绪,但第二次刷新页面时,出现以下错误: at ErrorHandler ->handle ('2', 'include(Header.php) [<a href='function.include'>fu

我有个奇怪的问题。我有两个php页面:
Index.html.php
Header.php
只包含在
Symfony2
项目上运行的html代码。索引页面包含一个非常普通的include:
include“Header.php”
。问题是,当我第一次加载索引时,页面正常呈现,所有内容都已就绪,但第二次刷新页面时,出现以下错误:

at ErrorHandler ->handle ('2', 'include(Header.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory', '', '30', array('template' => object(FileStorage), 'parameters' => array('app' => object(GlobalVariables)), '__template__' => object(FileStorage), 'this' => object(PhpEngine), 'app' => object(GlobalVariables), 'view' => object(PhpEngine)))
in wamp\www\**\src\**\**Bundle/Resources/views/Default/Index.html.php at line 30 

at include ()
in wamp\www\**\src\**\**Bundle/Resources/views/Default/Index.html.php at line 30 
at require ('')
in C:\wamp\www\**\app\cache\dev\classes.php at line 2490 

at PhpEngine ->evaluate (object(FileStorage), array('app' => object(GlobalVariables)))
in C:\wamp\www\**\app\cache\dev\classes.php at line 2440  

at PhpEngine ->render ('**Bundle:Default:Index.html.php', array())
in C:\wamp\www\**\app\cache\dev\classes.php at line 2778 

at PhpEngine ->renderResponse ('**Bundle:Default:Index.html.php', array(), null)
in C:\wamp\www\**\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine.php at line 87

at DelegatingEngine ->renderResponse ('**Bundle:Default:Index.html.php', array(), null)
in C:\wamp\www\**\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\Controller.php at line 99 

at Controller ->render ('**Bundle:Default:Index.html.php')
in C:\wamp\www\**\src\**\**Bundle\Controller\DefaultController.php at line 15

at DefaultController ->indexAction ()

at call_user_func_array (array(object(DefaultController), 'indexAction'), array())
in C:\wamp\www\**\app\bootstrap.php.cache at line 1421

at HttpKernel ->handleRaw (object(Request), '1')
in C:\wamp\www\**\app\bootstrap.php.cache at line 1385 

at HttpKernel ->handle (object(Request), '1', true)
in C:\wamp\www\**\app\bootstrap.php.cache at line 1561

at HttpKernel ->handle (object(Request), '1', true)
in C:\wamp\www\**\app\bootstrap.php.cache at line 612

at Kernel ->handle (object(Request))
in C:/wamp/www/**/web/app_dev.php at line 28
at ErrorHandler->handle('2','include(Header.php)[]:无法打开流:没有这样的文件或目录','30',数组('template'=>object(FileStorage),'parameters'=>array('app'=>object(GlobalVariables)),'this'=>object(PhpEngine),'app'=>object(GlobalVariables),'view'=>object(PhpEngine)))
在wamp\www\**\src\**Bundle/Resources/views/Default/Index.html.php的第30行
包括()
在wamp\www\**\src\**Bundle/Resources/views/Default/Index.html.php的第30行
按要求(“”)
在C:\wamp\www\**\app\cache\dev\classes.php的第2490行
在PhpEngine->evaluate(对象(文件存储),数组('app'=>对象(全局变量)))
在C:\wamp\www\**\app\cache\dev\classes.php的第2440行
在PhpEngine->render('**Bundle:Default:Index.html.php',array())
在C:\wamp\www\**\app\cache\dev\classes.php的第2778行
在PhpEngine->renderResponse('**Bundle:Default:Index.html.php',array(),null)
在C:\wamp\www\**\vendor\symfony\symfony\src\symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine.php的第87行
在DelegatingEngine->renderResponse('**Bundle:Default:Index.html.php',array(),null)
在C:\wamp\www\**\vendor\symfony\symfony\src\symfony\Bundle\FrameworkBundle\Controller\Controller.php的第99行
在Controller->render('**Bundle:Default:Index.html.php')
在C:\wamp\www\**\src\**Bundle\Controller\DefaultController.php的第15行
在DefaultController->indexAction()处
在调用\用户\函数\数组(数组(对象(DefaultController),'indexAction'),数组()时
在C:\wamp\www\**\app\bootstrap.php.cache的第1421行
在HttpKernel->handleRaw(对象(请求),“1”)
在C:\wamp\www\**\app\bootstrap.php.cache的第1385行
在HttpKernel->handle(对象(请求),'1',true)
在C:\wamp\www\**\app\bootstrap.php.cache的第1561行
在HttpKernel->handle(对象(请求),'1',true)
在C:\wamp\www\**\app\bootstrap.php.cache的第612行
在内核->句柄(对象(请求))
在第28行的C:/wamp/www/**/web/app_dev.php中

我检查了该文件,它确实存在于与索引文件相同的目录中。我也检查过信盒。注意,这个项目是由Symfony制作的,一切都进行得很顺利,但是当我创建了一个Sf2.1项目并将文件放在上面时,我遇到了这个问题。我正在使用Windows7和WAMPServer2.1。我希望我已经提供了关于这个问题的足够信息。

在第一次请求时,php呈现新模板,在下一次请求时,php呈现缓存中的模板。由于Header.php未被缓存,php引发未找到文件异常


使用渲染函数而不是包含。选中此项,或者只需将完整路径传递给include()

实际上,我在以前的项目中使用相同的方法调用include
Header.php
,但我没有遇到这个问题,但区别在于我使用的是Symfony2.0,而这个tims我使用的是Symfony2.1。这在最新版本中是新的吗?我刚刚在2.1.2版本中检查了它,它运行良好(在开发和产品环境中)。将供应商更新到最新版本和/或尝试将完整路径传递到Header.phpIt已经有一段时间了。我在忙别的事情。顺便说一句,真的很奇怪。我不必更新供应商,因为我下载了整个版本。我试着写了整条路,但我也犯了同样的错误。为什么不缓存包含的文件?!好的,呈现模板现在可以工作了,但是仍然需要对此进行解释。使用
Include''包含仍然有效的文件在Symfony 2.0.0中完美无瑕。