How to view the global configuration by composer
Editor to share with you how to view the global configuration of composer, I hope you will learn a lot after reading this article, let's discuss it together!
1. View the current image address
Enter the following command on the command line to view the image address:
$composer config-g repo.packagist {"type": "composer", "url": "https://packagist.org","allow_ssl_downgrade":true}"
You can also use composer config-l-g to view all global configurations
The following is to change the address to a Chinese image. If there is a problem with the Chinese image, you can restore it to the official default address. Here are the details.
2. Enable full mirroring service in China:
There are two ways to enable full mirroring service in China. The specific configuration methods are as follows:
1. System global configuration:
Add the configuration information to the global configuration file config.json of Composer. Modify the global configuration file for composer (recommended), open the command line and execute the following command:
The default address is changed to China Mirror address:
Composer config-g repo.packagist composer https://packagist.phpcomposer.com
Restore the Chinese image address to the default address: (note: this is to restore the Chinese image)
Composer config-g repo.packagist composer https://packagist.org
two。 Individual project configuration:
Configuration information is about to be added to the composer.json file of a project. There are two ways to modify the composer.json configuration file of the current project. Finally, you can add the following configuration information 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, the directory where the composer.json file is located), and execute the following command:
The default address is changed to China Mirror address:
Composer config repo.packagist composer https://packagist.phpcomposer.com
This command will automatically add the mirrored configuration information at the end of the composer.json file in the current project
Restore the Chinese image address to the default address: (note: this is to restore the Chinese image)
Composer config repo.packagist composer https://packagist.org
2.2 manually add the above information to the composer.json file
The default address is changed to China Mirror address:
"repositories": {"packagist": {"type": "composer", "url": "https://packagist.phpcomposer.com"}}"
Restore the Chinese image address to the default address: (note: this is to restore the Chinese image)
Change the value of url to: https://packagist.org
After reading this article, I believe you have a certain understanding of the method of composer to view the global configuration, want to know more about it, welcome to follow the industry information channel, thank you for reading!