Home > Development Tools > composer > Teach you how to configure composer China full image

Teach you how to configure composer China full image

藏色散人
Release: 2020-07-24 13:37:14
forward
4338 people have browsed it

The following tutorial column of composer will introduce to you the configuration of composer China full image. I hope it will be helpful to friends who need it!

Teach you how to configure composer China full image

Principle:

Because the composer installation package data is downloaded from github.com, the elements of the installation package The data is downloaded from packagist.org

As two foreign websites, the connection speed will be very slow, and it is very likely that the website will be blocked.

So composer China full image caches the installation package data and installation package metadata to the domestic computer room, and accelerates it through the domestic CDN,

In this way, we don’t have to request foreign websites when accessing Initiate a request, thus increasing the access speed.

Configuration:

So how do we use composer China full image?

First you can check the current address:

$ composer config -g repo.packagist
Copy after login

If the above error is reported, you can follow the prompts to add the -l parameter to view

$ composer config -g -l repo.packagist
Copy after login

You can see that the current mirror address is packagist.org. This is a foreign website, so every time you use composer, it is very slow.

We use the following command

$ composer config -g repo.packagist composer https://packagist.phpcomposer.com
Copy after login

to change the composer’s mirror address to the domestic address of https://packagist.phpcomposer.com

Check again after changing it


You can see that the mirror address has been changed. At this time, you can experience the speed of composer!

Attachment:

The above belongs to the image of system global configurationcomposer. If you only want to configure a project individually, enter the directory folder, execute

composer config repo.packagist composer https://packagist.phpcomposer.com
Copy after login

, that is, without the -g parameter. This command can modify the composer.json configuration file in the current folder and modify the composer image of the current project.

Add the above command to the composer.json file

"repositories": {
    "packagist": {
        "type": "composer",
        "url": "https://packagist.phpcomposer.com"
    }
}
Copy after login

You can also manually add the above content to complete the configuration.

The above is the detailed content of Teach you how to configure composer China full image. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template