Home  >  Article  >  Development Tools  >  A brief tutorial on Composer

A brief tutorial on Composer

藏色散人
藏色散人forward
2019-09-11 14:01:403410browse

A brief tutorial on Composer

Composer usage tutorial-Concise tutorial

Composer is a PHP Dependency management tools.

To use and install Composer, please make sure that PHP (version 5.3.2) has been installed correctly and the PHP environment variable is set (the one that can display the php version number using the command php -v).

Composer installation

Windows system

Installation directory.

For example, if installed under D:\Program Files\Composer, this directory will be used to set Composer's environment variables.

Download the composer.phar file to the installation directory.

Download the latest version: https://getcomposer.org/compo...

Download list page of each version: https://getcomposer.org/download

Installation Create an executable file named composer.bat in the directory and fill in the following line in the file:

@php "%~dp0composer.phar" %*

Set Composer environment variables

Right-click on the computer desktop "Computer" -> Menu "Properties" -> "Advanced System Settings" -> "Environment Variables" at the bottom -> Find the Path item in "System Variables", edit it, and add the Composer installation directory path to the variable value at the end Characters, such as;D:\Program Files\Composer (this is written according to your installation directory). Remember to use English semicolons; to separate multiple paths.

Test it (use DOS command window)

composer -V

Linux system/Mac OSX system

Operate under the terminal command line.

Enter the temporary download folder (anything, such as your home directory)

# cd ~

Download the composer.phar file

# wget https://getcomposer.org/composer.phar

Move and rename the composer.phar file to the binary directory

# mv composer.phar /usr/local/bin/composer 相当于设置Composer环境变量了

Set execution permissions, you must have execution permissions

# chmod 755 /usr/local/bin/composer

Test it

# composer -V

Using Composer

List Some commonly used ones.

composer self-update: Update composer version. (Of course, you can also download the composer.phar file to overwrite and update).

composer install: Install dependent code libraries based on the composer.json file in the current directory.

composer update: Update dependent code base.

composer create-project: Create a project.

composer init: Interactively create the composer.json file in the current directory.

Composer’s resources

Composer official website (English) 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

Welcome corrections

Original link on GitHub

https://github.com/wuyumin/tutorial/blob/master/zh-cn/Composer/README.md

You are welcome to star this project on GitHub or provide correction suggestions through Issues.

The above is the detailed content of A brief tutorial on Composer. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete