How to properly set PHP environment variable to run commands in Git Bash

后端 未结 4 1253
礼貌的吻别
礼貌的吻别 2020-12-11 03:35

There are a few similar questions as this throughout the site, but none of them are giving me the answer I\'m looking for.

What I\'m trying to do is install Composer

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-11 04:31

    If you prefer to have it all in the unixy context of your bash cmd window:

    1. Open the bash window and you find by default you're in the root directory

      $ pwd
      /
      
    2. change to your user directory

      $ cd ~
      $ pwd
      /c/Users/nickw
      
    3. create a .bash_profile file or append to an existing one (use single quotes or $PATH will get interpolated)

      $ echo 'PATH=$PATH:/i/wamp64/bin/php/php5.6.19' >> .bash_profile
      
    4. check the file has the entry

      $ cat .bash_profile
      PATH=$PATH:/i/wamp64/bin/php/php5.6.19
      
    5. close the bash window and open a new one to check

      $ php --version
      PHP 5.6.19 (cli) (built: Mar  2 2016 20:09:42)
      Copyright (c) 1997-2016 The PHP Group
      Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
      

提交回复
热议问题