I'm using Laravel 4 locally with EasyPHP 14.1. I have created a route :
Route::get('/test', function()
{
return View::make('test');
});
a layout (testlayout.blade.php) :
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<div class="container">
@yield('container')
</div>
</body>
</html>
and a view (test.blade.php) :
@extends("testlayout")
@section('container')
<h1>Hello!</h1>
@stop
It works fine and I get "Hello!"
But when a change my layout by adding an include like this :
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<div class="container">
@yield('container')
</div>
@include('testfooter')
</body>
</html>
with my footer (testfooter.blade.php) :
@section("testfooter")
<div class="footer">2013-2014</div>
@show
I have an error "syntax error, unexpected '/'".
The code generated by Laravel (found in app\storage\views) is wrong :
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<div class="container">
<?php echo $__env->yieldContent('container')
</div>
<?php echo $__env->make('testfooter', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>; ?>
</body>
</html>
Laravel forgets ;?>
after yieldContent('container')
and adds two ;?>
after ... render()
.
I've tried many things but I really don't have any clue now.
UPDATE1 I have reinstalled a fresh Laravel and guest what, the problem is still the same. Without @include it's ok, with an @include I have the same error again and again.
UPDATE2 and PROBLEM FIXED (thanks to @majimboo)! This is just unbelievable. All that story is not related to the code. This is a problem with the text editor : Notepad++ on Windows. For an unknown reason, and for somes files only, it switched from 'edit/EOL conversion/windows format' to 'edit/EOL conversion/Mac format'. And apparently, Laravel doesn't Mac format at all! So, if you use Notepad++ on Windows, be sure that you have : 'EOL conversion/windows format'
Usually Laravel gives a great hint to the problem. The problem might be in your CSS or JS include statements. First make sure you have turn on the debug mode of laravel. Here is how to do it.
I have intentionally leave out closing ')' of css file. The laravel FW showed where that error, and it will show you similar error.
Hope it help.
In my case the issue was an unterminated string in some PHP in a totally different part of the file than Laravel was complaining about. I eliminated it by removing everything in the file and adding the lines in again one by one.
the problem is in the file that is getting included.
First to check if the problem is really that, remove everything inside
testfooter.blade.php
then open the view from the browser. You'll notice that there is no error anymore.Change your
testfooter.blade.php
to:remove the
@section("testfooter")
...@show
.Example:
You include it like:
Check this to learn more on blade.
The problem seems to be something else, I would just like to share this, If it can help you:
You have this:
Change it to this: