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!
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}
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
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
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" } }
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
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
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" } }
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!