Search code examples
phpmacoscomposer-phphomebrewmcrypt

Why did installing php53-mcrypt break my composer and laravel?


I am very new to laravel and php and I am just trying to set up my development environment.

I am interested in using octobercms and installing it has been anything but simple. I tried the console installation by typing

composer create-project october/october myoctober dev-master

which gave an error saying mcrypt wasn't installed so I thought that was my next step. After spending hours trying to figure out how to install it I came across this

homebrew/php/php53-mcrypt

and I brew installed it. Now, laravel and my composer won't work. Every time I write any sort of composer command, I get this:

??+?% returned

No one on google seems to have this problem and every time I write and laravel command in the terminal I get some sort of error like this:

PHP Parse error:  syntax error, unexpected '[', expecting ')' in /Users/marika/.composer/vendor/guzzlehttp/promises/src/functions.php on line 41

Parse error: syntax error, unexpected '[', expecting ')' in /Users/marika/.composer/vendor/guzzlehttp/promises/src/functions.php on line 41

it was all working before I brew installed mcrypt and I tried to uninstall but that just gave me more errors, so I reinstalled and now I don't know what else to do.


Solution

  • You have the wrong php version. At line 41 of the functions.php of guzzle, it says:

        $promise = new Promise([$queue, 'run']);
    

    which is short array syntax. You will need php5.4 to run your code, as the doc states:

    As of PHP 5.4 you can also use the short array syntax, which replaces array() with [].

    As you are on MacOS, in order to get a more up to date version of PHP, install a newer version via:

    brew tap homebrew/dupes
    brew tap homebrew/versions
    brew tap homebrew/homebrew-php
    brew install php56
    brew unlink php53
    brew link php56
    

    Source