Reputation: 9937
I have the following error when install laravel dependencies with composer
PHP Parse error: parse error in laravel/framework/src/Illuminate/Support/helpers.php on line 411.
I looked at the source code of https://github.com/laravel/framework/blob/master/src/Illuminate/Support/helpers.php#L411
$results = [];
I believe the reason of this is the new array syntax of php.
It seems like the library has some incompatibilities.
Below is my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
Upvotes: 0
Views: 889
Reputation: 4127
You say you're running OS X, but:
Even without knowing the above, the line in question has the following:
$results = [];
Meaning it's creating an array with short syntax which is only supported by PHP 5.4+. You probably have an earlier version, hence the syntax error.
I'd say update PHP if you can, or use Laravel 4.1 if you can't.
Update:
If you have a compatible PHP already installed, it's probably just a matter of pointing Composer to the proper version. Just open a new Terminal window and type cd ~
, then create a .bash_profile
file by typing vim .bash_profile
. Check the path of your XAMPP php folder (I haven't verified the path below, it's just a best-guess example), and add it to the new file:
export XAMPP_PHP=/Applications/XAMPP/xamppfiles/bin
export PATH="$XAMPP_PHP:$PATH"
Save it (esc > type :wq > enter), then reopen Terminal and try php -v
and which php
to see if Terminal is now using your XAMPP PHP. If not, check the path and try again!
Upvotes: 2