Modify Mac default PHP runtime environment and configure global Composer for MAMP

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.