PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 31, 2022

[FIXED] Laravel dependencies error Composer install error in Mac OSX

 January 31, 2022     composer-php, laravel-4     No comments   

Issue

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"

}


Solution

You say you're running OS X, but:

  • What is your PHP version?
  • How are you running your server (i.e. MAMP, plain Apache, Vagrant)?

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!



Answered By - Tomas Buteler
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing