http://pkg.phpcomposer.com/
Http://www.yiichina.com/doc/guide/2.0/intro-upgrade-from-v1
Https://getcomposer.org/doc/01-basic-usage.md
Packagist Mirroring
Please use this image of the students to note:
This image has been fully upgraded in accordance with composer's official data source security policy and supports the HTTPS protocol! Please follow the two methods shown below to change the revision to http://packagist.phpcomposer.com
https://packagist.phpcomposer.com
Haven't you installed Composer yet? Please look down how to install Composer.
Usage:
There are two ways to enable this mirroring service:
- System global Configuration: Adds the configuration information to the Composer global configuration file
config.json
. See "Example 1"
- Single project configuration: Adds configuration information to a
composer.json
file in a project. See "Example 2"
Example 1: Modifying the global configuration file for composer (recommended)
Open a command-line window (Windows user) or console (Linux, MAC user) and execute the following command:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
Example 2: Modify the configuration file for the current project composer.json
:
Open a command-line window (Windows user) or console (Linux, MAC user), enter the root directory of your project ( composer.json
that is, the directory where the files are located), and execute the following command:
composer config repo.packagist composer https://packagist.phpcomposer.com
The above command will automatically add the mirrored configuration information at the end of the file in the current project composer.json
(you can also manually add it yourself):
"repositories": { "packagist": { "type": "composer", "url": "https://packagist.phpcomposer.com" }}
Take the composer.json
configuration file for the Laravel project as an example, following the above command (note the last few lines):
{ "Name ":"Laravel/laravel", "Description ":"The Laravel Framework.", "Keywords ":["Framework","Laravel"], "License ":"MIT", "Type ":"Project", "Require ":{ "PHP ":">=5.5.9", "Laravel/framework ":"5.2.*"}, "Require-dev ":{ "Fzaninotto/faker ":"~1.4", "Mockery/mockery ":"0.9.*", "Phpunit/phpunit ":"~4.0", "Symfony/css-selector ":"2.8.*|3.0.*", "Symfony/dom-crawler ":"2.8.*|3.0.*"}, "AutoLoad ":{ "Classmap ":["Database"], "Psr-4 ":{ "App\\ ":"App/"}}, "Autoload-dev ":{ "Classmap ":["Tests/testcase.php"]}, "Scripts ":{ "Post-root-package-install ":["Php-r \" Copy ('. Env.example ', '. env '); \ ""], "Post-create-project-cmd ":["PHP artisan key:generate"], "Post-install-cmd ":["PHP Artisan clear-compiled","PHP artisan Optimize"], "pre-update-cmd ": [" PHP Artisan Clear-compiled "]," post-update-cmd ": [ "PHP artisan Optimize"]}, "config": {"preferred-install": "Dist"}, "repositories": {"packagist": {" type ": " composer " , "url": "https:// Packagist.phpcomposer.com "}}}
OK, everything is done! Try composer install
to experience the speed of flying!
Image description:
In general, the data of the installation package (mainly the zip file) is usually downloaded from the download github.com
, and the metadata of the installation package is downloaded from the download packagist.org
.
However, due to well-known reasons, foreign websites are slow to connect and may be "wall" or "nonexistent" at any time.
"Packagist China Full-volume mirror" does is to cache all the installation package and metadata to the domestic engine room and through the domestic CDN to accelerate, so that no longer to the foreign site to initiate the request, so as to accelerate composer install
composer update
the process, and faster and more stable. As a result packagist.org
, github.com
you can still download and update the installation package even if, in the event of a failure (mainly the connection speed is too slow and the wall is blocked).
How to install Composer
Be sure to install PHP correctly before installing it. Open a command-line window and perform a php -v
check to see if the version number is output correctly.
Open the command line and execute the following command to install the latest version of Composer (the following instructions are taken from https://getcomposer.org/download/, go to view the latest installation instructions):
"readfile(‘https://getcomposer.org/installer‘);" > composer-setup.phpphp composer-setup.phpphp -r "unlink(‘composer-setup.php‘);"
Executing the first command to download the composer-setup.php
script will simply detect php.ini
the parameters in the set, if some parameters are not set correctly will give a warning, and then download the latest version of the composer.phar
file to the current directory.
The functions of the above 3 commands are:
- Download the installation script (
composer-setup.php
) to the current directory.
- Perform the installation process.
- Delete the installation script--
composer-setup.php
.
Partial installation
After the process of downloading Composer is done correctly, you can composer.phar
copy the files to any directory (such as the project root directory) and then use the Composer with the php composer.phar
instructions!
Global Installation
The global installation is to install Composer PATH
under the path contained in the system environment variable, and then execute the command directly in the command composer
-line window.
Mac or Linux system: Open a command-line window and execute the following command to move the previously downloaded composer.phar
file to the /usr/local/bin/
directory:
sudo mv composer.phar /usr/local/bin/composer
Windows System:
- Locate and go to the installation directory of PHP (and the instructions you execute on the command line
php
should be the same set of PHP).
- will be
composer.phar
copied to PHP under the installation directory, that is, and php.exe
in the same level directory.
- Create a new file in the PHP installation directory
composer.bat
and save the following code to this file.
"%~dp0composer.phar" %*
Finally reopen a command-line window and try it out to composer --version
see if the version number is correctly printed.
At last
Tip: Don't forget to do it often composer selfupdate
to keep Composer always the latest version Oh!
PHP composer China Full-volume mirror