Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fenos's avatar

Mac doesn't recognise composer

Hi guys, I bought a mac few days ago, I set up my vagrant and homestead, and work perfectly.

The problem is: I have a gulpfile.js that run some tasks example, trigger tests on save etc... So running gulp test on my Mac terminal it should start the watcher, but instead gulp work fine when it come to run phpspec command (I guess) it throw me an error

Starting 'test'...
[11:19:48] Finished 'test' after 5.45 ms
[11:19:49] You must set up the project dependencies, run the following commands:
curl -s http://getcomposer.org/installer | php
php composer.phar install

But I already installed composer globally via brew, if I type composer it show Up the composer commands.

Please guys, help me to fix this

0 likes
15 replies
bashy's avatar

Install it manually from https://getcomposer.org

Download it and do this command to move it (may need sudo)

<sudo> mv composer.phar /usr/local/bin/composer

Results in

~ » composer -V
Composer version b33da336ecb7f1c9b15a57285e5a9f09cf5f3dd2 2014-09-30 15:28:01
fenos's avatar

I done that, but it give me the same problem, thanks for your help, do you have any others idea?

fenos's avatar

I removed the composer from brew list and keep it only the composer installed manually, yes I use that plugin. It was working perfect on my previous Ubuntu OS. I really don't understand why running phpspec from my Mac terminal give me that error. Even if I run only phpspec run give me the same problem

What else may try? I'm still a noob with Mac

bashy's avatar

Could be missing the path

Check echo $PATH or $path

~ » echo $PATH
/usr/local/php5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin


~ » echo $path
/usr/local/php5/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin
fenos's avatar

Thanks, doing echo $PATH this is the output:

echo $PATH
/usr/local/Cellar/php56/5.6.0/bin:/Applications/MAMP/bin/php/php5­.5.14/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

doing echo $path nothing come out

Should I change it like the your one?

keevitaja's avatar

no, just make sure that the location of your composer is in the path!

1 like
fenos's avatar

@keevitaja thanks but, my composer is in this path /usr/local/bin/composer which path of the many I see in my output it should stay?

keevitaja's avatar

You're all set as /usr/local/bin/ is in your PATH!

I am not sure about $path ver $PATH

fenos's avatar

@keevitaja Thanks again, but I didn't get it yet sorry :(. If i run composer everywhere in my terminal it is working, it show me the list of all the commands, I can even do composer update on my project. When i run phpspec come out this issue, so i cannot execute my tests automatically

bashy's avatar

$path is probably ZSH specific. You doing the command on VM or local?

Not sure otherwise...

fenos's avatar

I run gulp test or phpspec locally not In my VM

bashy's avatar

So what does composer install return?

1 like
fenos's avatar

wow thanks it bring me a step forward, composer install throw me an exception:

Mcrypt PHP extension required.
Script php artisan clear-compiled handling the post-install-cmd event returned with an error



  [RuntimeException]  
  Error Output:       

So i googled on how to install Mcrypt php extension on mac and it needs to change a lots configuration files, when in ubuntu i could do just sudo apt-get install php5-mcrypt and I done. Now there is a way more quick to do that in mac? something like brew view point?

nWidart's avatar

This means Mac os doesn't point to your correct php bin. If you've MAMP installed add that path to your $PATH. You shouldn't have that error if you run it from the VM though.

Something like:

export MAMP_PHP=/Applications/MAMP/bin/php/php5.5.14/bin
export PATH="$MAMP_PHP:$PATH"

Please or to participate in this conversation.