Home  >  Article  >  Backend Development  >  Composer update failed, enable the configuration change method of domestic mirror website

Composer update failed, enable the configuration change method of domestic mirror website

WBOY
WBOYOriginal
2016-08-08 09:22:151501browse

Usage:

There are two ways to enable this mirror service:

  1. Add the following configuration information to the Composer configuration file config.json (system global configuration). See "Example 1"
  2. Add the following configuration information to your project's composer.json file (for single project configuration). See "Example 2"
In order to avoid executing two queries when installing the package, remember to add the setting to disable packagist, as follows:
        {
            "repositories": [
                {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"},
                {"packagist": false}
            ]
        }
        

Example 1, modify the composer configuration file

View the composer home directory: The global configuration information of composer can be listed through the composer config -l -g command, and the [home] configuration item found in this information is the home directory of composer. Linux users please execute the sudo composer config -l -g command.

Enter the composer's home directory, open the config.json file (if it doesn't exist, create one yourself), and then add the configuration information of this mirror service. The final content is as follows:

        {
            "config": {

            },
            "repositories": [
                {"type": "composer", "url": "http://pkg.phpcomposer.com/repo/packagist/"},
                {"packagist": false}
            ]
        }
        

Example 2, using the composer.json configuration file of the laravel project For example, after adding the configuration information of this mirror service, it is 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}
            ]
        }
        

The above introduces how to change the configuration of the domestic mirror website if the composer update is unsuccessful, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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