[Switch] Composer China Image

Source: Internet
Author: User

Usage:

You can enable the image service in either of the following ways:

    1. Add the following configuration information to the configuration file config. JSON of composer (global configuration of the system ). See "Example 1"
    2. Add the following configuration information to the composer. JSON file of your project (for a single project ). See "Example 2"
To avoid executing two queries during the installation package, you must add the following settings to disable packagist:
        {            "repositories": [                {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"},                {"packagist": false}            ]        }        
Example 1: Modify the composer configuration file

View the main directory of composer:Composer config-L-GCommand to list the global configuration information of composer.[Home]The configuration item is the main directory of composer. RunSudo composer config-L-GCommand.

Go to the main directory of composer, open the config. JSON file (if there is no such file), and add the configuration information of the Image Service. The final content is as follows:

        {            "config": {            },            "repositories": [                {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"},                {"packagist": false}            ]        }        
Example 2: Use the composer. JSON configuration file of the laravel project as an example to add the configuration information of the Image Service as follows (note the last few lines ):
        {            "name": "laravel/laravel",            "description": "The Laravel Framework.",            "keywords": ["framework", "laravel"],            "license": "MIT",            "type": "project",            "require": {                "laravel/framework": "4.2.*"            },            "autoload": {                "classmap": [                    "app/commands",                    "app/controllers",                    "app/models",                    "app/database/migrations",                    "app/database/seeds",                    "app/tests/TestCase.php"                ]            },            "scripts": {                "post-install-cmd": [                    "php artisan clear-compiled",                    "php artisan optimize"                ],                "post-update-cmd": [                    "php artisan clear-compiled",                    "php artisan optimize"                ],                "post-create-project-cmd": [                    "php artisan key:generate"                ]            },            "config": {                "preferred-install": "dist"            },            "minimum-stability": "stable",            "repositories": [                {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"},                {"packagist": false}            ]        }        
Note:

Using this image service means that all the downloaded installation package metadata will come from this image service and will not initiate a request to packagist.org. This will accelerate the installation process of composer and make it more reliable and fast. (Due to the well-known reasons, the connection speed of foreign websites is too slow and may be blocked at any time)

Generally, the data of the installation package (such as ZIP files) is downloaded from GitHub or other third-party servers. After using this image service, we will cache all installation packages to data centers in China, in this way, you no longer need to send requests to foreign websites. Therefore, even if packagist.org, github.com, or other third-party services fail (the connection speed is too slow and the connection is blocked ), you can still download and update the installation package.

[Switch] Composer China Image

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.