Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4 syntax error out-of-the-box

I just installed Laravel 4 (Illuminate) and as I opened the index.php file in a browser, I was met with this error:

Parse error: syntax error, unexpected 'yield' (T_YIELD), expecting identifier (T_STRING) in /www/Laravel4/vendor/illuminate/view/src/Illuminate/View/Environment.php on line 339

I have fixed the permissions for the meta folder, and installed all the dependencies through Composer. I am running PHP version 5.5.0alpha2 on OSX 10.8.2.

like image 555
Erik Djupvik Avatar asked Dec 21 '12 12:12

Erik Djupvik


1 Answers

That's because yield became a language construct in PHP 5.5 (used in Generators) - but someone decided that it's a good idea to use this short word to name a function:

public function yield($section)
{
  return isset($this->sections[$section]) ? $this->sections[$section] : '';
}

Downgrade to PHP 5.4 (after all, it's the current mainstream version, 5.5 is not even in beta yet) and it should work fine.

like image 73
raina77ow Avatar answered Sep 30 '22 16:09

raina77ow