-1

I've somehow got myself in a situation where to run any terminal commands I have to prefix it with php. For example to run composer commands I have to run:

php /Applications/MAMP/bin/php/composer

The problem I'm having is that when I then try to install a new laravel project by running:

php /Users/ian/.composer/vendor/bin/laravel new my-project

I get the error:

sh: composer: command not found

What is the best way to resolve this so I don't get the above error and can just use composer again going forward?

Nico Haase
  • 11,420
  • 35
  • 43
  • 69
rushtoni88
  • 4,417
  • 7
  • 22
  • 31

1 Answers1

2

The path to the composer is probably missing in the PATH variable (I am assuming you are using Linux).

export PATH=$PATH:/Applications/MAMP/bin/php/composer
geldek
  • 503
  • 2
  • 10
  • Ye, I'm using Linux. I've added the above to my .zshrc but if I run ```composer``` I now get ```zsh: permission denied: composer``` – rushtoni88 Nov 11 '21 at 13:50
  • Using ```sudo``` I still get ```sudo: composer: command not found``` – rushtoni88 Nov 11 '21 at 14:03
  • 1
    Are you using Linux or MacOS. I'm pretty sure MAMP is not available on Linux – trommelaap Nov 11 '21 at 14:34
  • sudo does not preserve environment by default. There are several ways how to bypass that. See: https://unix.stackexchange.com/questions/83191/how-to-make-sudo-preserve-path – geldek Nov 11 '21 at 15:21