I got a weird problem. I’ve simply two php pages: Index.html.php and Header.php containing just HTML codes running on a Symfony2 project. The Index page contains a very normal include: include "Header.php". The problem is that, when I load the Index for the first time the page renders normally, everything is in place, but the second time I refresh the page, I got this error:
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
I checked the file, it really exists in the same directory as the Index file. I checked the letter cases either. Notice that the project was made out of Symfony and every things went well, but when I created a Sf2.1 project and put the files on I got this problem. I’m using Windows7 and WampServer 2.1. I wish I’ve provided enough info about the issue.
On first request php renders fresh template, on the next requests php renders templates from cache. since Header.php is not cached php throws file not found exception.
Use render function instead of include. Check this Including other Templates or you can just pass full path to include()