How to view global configuration in composer

藏色散人
Release: 2020-06-15 13:30:11
forward
6186 people have browsed it

The following tutorial column of composer will introduce to you how to view the global configuration of composer. I hope it will be helpful to friends in need!

How to view global configuration in composer

1. Check the current mirror address

Enter the following command on the command line to check the mirror address:

$ composer config -g repo.packagist
{"type":"composer","url":"https://packagist.org","allow_ssl_downgrade":true}
Copy after login

You can also use composer config -l -g View all global configurations

The address is changed to the Chinese image below. If there is a problem with the Chinese image, you can restore it to the official default address. The details are below.

2. Enable China Full Mirror Service:

There are two ways to enable China Full Mirror Service. The specific configuration methods are as follows:

1. System global configuration:

Add configuration information to Composer's global configuration file config.json. Modify the global configuration file of composer (recommended method), open the command line and execute the following command:

Change the default address to the Chinese mirror address:

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

Restore the Chinese mirror address to the default address: (Note : This is to restore the Chinese image)

composer config -g repo.packagist composer https://packagist.org
Copy after login

2. Single project configuration:

About to add the configuration information to the composer.json file of a certain project. There are two ways to modify the composer.json configuration file of the current project. In the end, the following configuration information is added to the file:

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

2.1 Open the command line and enter the root directory of the project (that is, where the composer.json file is located directory), execute the following command:

Change the default address to the Chinese mirror address:

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

This command will automatically add the mirror configuration information at the end of the composer.json file in the current project

Restore the Chinese mirror address to the default address: (Note: This is to restore the Chinese mirror)

composer config repo.packagist composer https://packagist.org
Copy after login

2.2 Manually add the above information to the composer.json file

Change the default address For the Chinese mirror address:

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

Restore the Chinese mirror address to the default address: (Note: This is to restore the Chinese mirror)

Change the value of the url to: https:// packagist.org

For more composer technical articles, please visit the composer column!

The above is the detailed content of How to view global configuration in composer. 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