PHP Package management tool Composer Simple summary

Source: Internet
Author: User
Tags composer install

Objective

After contact Laravel, only then know has psr,composer such things, PHP is no longer a grassroots language. Recently trying to play thrift, need to install PHP Thrift dependent Library, using composer install apache/thrift will prompt Composer.json file does not exist, this file does not exist, can't install it? Later found to be installed through the composer require Apache/thrift, this command will attempt to create a Composer.json configuration file. Through this matter, found to composer still do not know very much, so took a little time to learn more, so use their own language to weave this article.

Implementation principle

Get package meta information, project source address library download package and dependent package, install to local

Installation

Composer need php5.3.2+ version and need to open Phar Extension

Composer is executable in a Linux shell environment written by PHP and compressed using PHP Phar (the Phar format file can be executed via the PHP command line)
[Email protected] ~]$ Curl-ss Https://getcomposer.org/installer | Php


[Email protected] wadeyu]# MV Composer.phar/usr/local/bin/composer

Configuration

Set Mirror Address (Chinese mirror address-G parameter indicates global configuration)

Composer Config-g Repo.packagist composer https://packagist.phpcomposer.com

Set process Execution time-out (in seconds)

Composer Config-g Process-timeout 600

View the configuration list

Composer Config-g-L

Configuration file Description
A file named Composer.json under the project root, using the JSON format to define the project or package-related information

Use

Composer Command Automatic update (sometimes not updated: ()

Composer Self-update

declaring a dependency package (The current execution directory does not exist Composer.json will attempt to create)

Composer require package name

Install package (Composer.json claims a dependency package that needs to be installed)

Composer Install

Update package

Composer Update [package Name 1 package Name 2 ...]

Search Packages (It is slower to perform a remote search without a Composer.json profile: ()

Composer Search Mode character

Postscript

I probably understand the next, and now basically can meet my daily use, behind the problem can see the resources below. It should be possible to build a local package metadata service and a code management service for the source code download when you need to share code between multiple projects and not publish to a public warehouse, which I have not tried: (

Resources
"1" composer Chinese web
http://www.phpcomposer.com/
"2" composer Tool manual
https://getcomposer.org/download/
"3" Packagist/composer China Full-volume mirror
http://pkg.phpcomposer.com/
"4" Composer.json Configuration detailed description
Http://docs.phpcomposer.com/04-schema.html
Basic usage of "5" composer
Http://docs.phpcomposer.com/01-basic-usage.html

PHP Package management tool Composer Simple summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.