<codemicrosoft yahei color:rgb white-space:pre-wrap padding:0px border:0px margin-top:-1.2em display:block background:0px> Could not open input file: composer.phar </codemicrosoft>
<codemicrosoft yahei color:rgb white-space:pre-wrap padding:0px border:0px margin-top:-1.2em display:block background:0px> mv composer.phar /usr/local/bin/composer </codemicrosoft>
<codemicrosoft yahei color:rgb white-space:pre-wrap padding:0px border:0px margin-top:-1.2em display:block background:0px> php composer.phar update </codemicrosoft>
<codemicrosoft yahei color:rgb white-space:pre-wrap padding:0px border:0px margin-top:-1.2em display:block background:0px> which php /usr/bin/php </codemicrosoft>
<codemicrosoft yahei color:rgb white-space:pre-wrap padding:0px border:0px margin-top:-1.2em display:block background:0px><span>sudo</span> nano ~/.bash_profile <span># 添加一行。注意 PHP5.4.10 修改成你正在运行的 PHP 版本目录名称</span><span>export</span> PATH=<span>"/Applications/MAMP/bin/php/php5.4.10/bin:<span>$PATH</span>"</span><span># 保存,退出</span><span># 运行一下 .bash_profile 文件</span> . .bash_profile <span># 确认当前正在运行哪个 PHP</span> which php /Applications/MAMP/bin/php/php5.<span>4.10</span>/bin/php </codemicrosoft>
<codemicrosoft yahei color:rgb white-space:pre-wrap padding:0px border:0px margin-top:-1.2em display:block background:0px><span>cd</span> /usr/local/bin curl <span>-s</span>S https://getcomposer.org/installer | php Composer successfully installed to: /usr/local/bin/composer.phar Use it: php composer.phar <span># 修改一下 composer.phar 文件的权限</span><span>sudo</span> chmod a+x composer.phar </codemicrosoft>
<codemicrosoft yahei color:rgb white-space:pre-wrap padding:0px border:0px margin-top:-1.2em display:block background:0px><span>cd</span> /my/project/path <span># 注意此时 composer.phar 命令前面已经不需要加 php 了</span> composer.phar create-project composer.phar self-update composer.phar install composer.phar update </codemicrosoft>
上記では、Mac のデフォルトの PHP 実行環境を変更し、MAMP 用にグローバル Composer を構成する方法を、関連する内容も含めて紹介しています。PHP チュートリアルに興味のある友人に役立つことを願っています。