How to use Composer
This article mainly introduces how to use Composer, has a certain reference value, friends in need can refer to. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
Composer usage tutorial-Concise tutorial
Composer is a dependency management tool for PHP.
To use and install Composer, make sure that PHP (version 5.3.2 +) is installed correctly and that the environment variable for PHP is set (that is, the php version number can be displayed using the command php-v).
Installation of Composer
Windows system
Installation directory.
For example, if you install it under D:\ Program Files\ Composer, this directory will be used to set the environment variables for Composer.
Download the composer.phar file to the installation directory.
Download the latest version: https://getcomposer.org/compo...
Download list page for each version: https://getcomposer.org/download
Create an execution file named composer.bat under the installation directory and fill in the file with the following line:
@ php "% ~ dp0composer.phar"% *
Set the Composer environment variable
On the computer desktop, right-click "computer"-> menu "Properties"-> "Advanced system Settings"-> under "Environment variables"-> "system variables" to find the Path entry, edit the variable value and add the Composer installation directory path characters at the end, such as: d:\ Program Files\ Composer (this is written according to your installation directory), remember to use English semicolons between multiple paths; separate.
Test it (use the DOS command window)
Composer-V
Linux system / Mac OSX system
Operate under the terminal command line.
Go to the temporary download folder (feel free, such as your own home directory)
# cd ~
Download the composer.phar file
# wget https://getcomposer.org/composer.phar
Move and rename composer.phar files to binary directory
# mv composer.phar / usr/local/bin/composer is equivalent to setting the Composer environment variable
Set execution permission. You must have execution permission.
# chmod 755 / usr/local/bin/composer
Test it
# composer-V
The use of Composer
List some commonly used ones.
Composer self-update: update the composer version. (of course, you can also download the composer.phar file to overwrite and update).
Composer install: install the dependent code base based on the composer.json file in the current directory.
Composer update: update the dependent code base.
Composer create-project: create a project.
Composer init: interactively creates composer.json files in the current directory.
Resources for Composer
Composer official website https://getcomposer.org
PHP installation package list (English) https://packagist.org
Composer Chinese website (Chinese) http://www.phpcomposer.com
Packagist/Composer China full Mirror (Chinese) http://pkg.phpcomposer.com
Amendments are welcome.
You are welcome to star this project on GitHub or provide correction suggestions through Issues.
Thank you for reading this article carefully. I hope it will be helpful for everyone to share how to use Composer. At the same time, I also hope you will support us, pay attention to the industry information channel, and find out if you have any problems. Detailed solutions are waiting for you to learn!