Home >Backend Development >PHP Tutorial >composer installation, composer_PHP tutorial
Make sure you have PHP installed correctly.
Partial installation is to install composer to the current directory (such as installing it to the project root directory), and then you can use composer through php composer.phar
.
Mac or Linux system: Open a command line window and execute the following command:
<code class="language-bash hljs">curl <span class="hljs-operator">-sS http://install.phpcomposer.com/installer | php </span></code>
Windows system (Mac or Linux system can also be used): Please execute the following command:
<code class="language-bash hljs">php -r <span class="hljs-string">"readfile('http://install.phpcomposer.com/installer');" | php</span></code><br /><br />
Global installation is to install composer to the path contained in the system environment variable PATH
, and then you can directly execute the composer
command in the command line window.
Mac or Linux system: Open a command line window and execute the following command:
<code class="language-bash hljs">curl <span class="hljs-operator">-sS http://install.phpcomposer.com/installer | sudo php -- --install-dir=/usr/<span class="hljs-built_in">local/bin --filename=composer </span></span></code>
Windows system: Please execute the following command in the command line:
<code class="language-bash hljs">mkdir C:\bin <span class="hljs-built_in">cd C:\bin php -r <span class="hljs-string">"readfile('http://install.phpcomposer.com/installer');" | php <span class="hljs-built_in">echo @php <span class="hljs-string">"%~dp0composer.phar" %*>composer.bat </span></span></span></span></code>
After the above command is successfully executed, add the C:bin
path to the PATH
environment variable. Finally, reopen a command line window and try executing composer --version
to see if the version number is correctly output, for example:.
<code class="hljs css"><span class="hljs-tag">Composer <span class="hljs-tag">version 1<span class="hljs-class">.0-dev (72<span class="hljs-tag">cd6afdfce16f36a9fd786bc1b2f32b851e764f) 2015<span class="hljs-tag">-12-28 17<span class="hljs-pseudo">:35<span class="hljs-pseudo">:19</span></span></span></span></span></span></span></code>