: This article describes how to modify the default Mac PHP runtime environment and configure global Composer for MAMP. For more information about PHP tutorials, see. If the global Composer is not configured, if you run the Composer command in the directory where the Composer is not installed, for example, the create-project system will return:
Could not open input file: composer.phar
Well, let's find out why. let's take a look at the Composer document and say we want to move Composer to the/usr/local/bin directory:
mv composer.phar /usr/local/bin/composer
Run the Composer command again. let's look at the Composer document. all Composer commands have a PHP file, for example:
php composer.phar update
Composer depends on PHP. well, at least it is not a problem with Composer. it may be a problem with PHP, we all know that when Mac is released, a PHP is preset in the system and mamp php is used. This may be the problem. run the following command in Terminal:
which php/usr/bin/php
The problem was confirmed, that is, the PHP problem. to be precise, it is a problem with the PHP environment configuration. configure the environment by yourself:
Sudo nano ~ /. Bash_profile # Add a row. Note that PHP5.4.10 is changed to the directory name of the PHP version you are running export PATH = "/Applications/MAMP/bin/php/php5.4.10/bin: $ PATH" # save and exit # run it. bash_profile file .. bash_profile # confirm which PHPwhich php/Applications/MAMP/bin/php/php5.4.10/bin/php is currently running
Now, the PHP runtime environment has been configured. please reinstall Composer:
Https://getcomposer.org/installer | phpComposer successfully installed to:/usr/local/bin/composer. pharUse it: php composer. phar # modify composer. sudo chmod a + x composer. phar
Oh, run the Composer command:
Cd/my/project/path # note that at this time composer. phar command in front of no need to add php composer. phar create-projectcomposer.phar self-updatecomposer.phar installcomposer. phar update
Done! Now, you should eat and eat, and go to bed.
The above describes how to modify the Mac default PHP runtime environment and configure global Composer for MAMP, including some content. I hope to help anyone who is interested in the PHP Tutorial.