Php – Composer update/create-project/install – HTTP Request failed

composer-phpphp

Recently I learned about Laravel 4.2. Then I switched to Laravel 5. All the time I've used composer to add another dependencies and stuff, I had no problems at all.

Last Thursday I've created a new project using composer create-project laravel/laravel dir_name --prefer-dist. All went ok.

But since Friday, I cannot do anything. Every time I try to create new project, update dependencies or do anything, there is a long wait (almost like freeze) and then errors. They usually are about HTTP request failed or problems with packagist.org.

At work I don't have any issues. My friend doesn't either. It worked on my PC and suddenly stopped. Please help.

C:\xampp\htdocs\dir_name>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
The "http://packagist.org/p/symfony/routing$0b411061e305b2d7a108caca01c21b859b6a2be133eff320b93e64d8
c5759e2b.json" file could not be downloaded: failed to open stream: HTTP request failed!
http://packagist.org could not be fully loaded, package information was loaded from the local cache
and may be out of date

[here freezes for good (more than 20 minutes), killed]

My composer is up-to-date:

C:\xampp\htdocs\dir_name>composer self-update
You are already using composer version 9fb2d4f2d642a0749decb41bc2fe4be2bf8bef7a.

C:\xampp\htdocs\dir_name>

And that's composer update -vvv:

C:\xampp\htdocs\dir_name>composer update -vvv
Reading ./composer.json
Loading config file C:/Users/Forien/AppData/Roaming/Composer/config.json
Loading config file C:/Users/Forien/AppData/Roaming/Composer/auth.json
Loading config file ./composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Executing command (CWD): hg branch
Executing command (CWD): svn info --xml
Failed to initialize global composer: Composer could not find the config file: C:/Users/Forien/AppDa
ta/Roaming/Composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.
org/ "Getting Started" section
Loading composer repositories with package information
Downloading https://packagist.org/packages.json

[freeze for over 15 minutes here, killed]

In home I'm behind routers, but no proxy I'm aware of. I have no idea what has changed. As of composer.json – even with brand new clean .json from laravel/laravel, update does not launch properly.

Any help appreciated. Do you have any ideas why this happened or how to fix this?

Edit

composer diagnose
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be
 downloaded: SSL: Handshake timed out
Failed to enable crypto
failed to open stream: operation failed
Checking github.com oauth access: OK
Checking disk free space: OK
Checking composer version: OK

Composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "laravel/framework": "5.0.*"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1",
        "filp/whoops": "^1.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "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 -r \"copy('.env.example', '.env');\"",
            "php artisan key:generate"
        ]
    }
}

Best Solution

I have tried it here and i have cloned a new laravel5 project with composer.

composer create-project laravel/laravel --prefer-dist

Like your log mentioned you can't open the routing dependency because the given json file isn't present and you get an 404 error. So i think any of your dependencies are not correct.

Routing JSON

I have no problems at all and can clone a new project with all dependencies. Its working well. Is it possible that you have added some 3rd party dependencies for some functions in your composer.json and that projects have dependencies that are wrong or not present anymore?

What i should try is to first clean all caches.

composer clear-cache

And to be sure that everything is working you can run the diagnostic.

composer diagnose

Next try to check all your dependencies. Here is a fresh composer.json.

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "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-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

Sometimes i have here the problem if i try to clone something it takes a lot of time until the service respond but in your case its much to long.

I would suggest to enable the openssl extension. You can't make an SSL connection.

Checking http connectivity: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be
 downloaded: SSL: Handshake timed out

Check that in your phpinfo() and your can make another check with a clean file:

<?php
echo file_get_contents("https://packagist.org/packages.json");

To avoid that your command line use another php interpreter or another version where openssl is not enabled you can test it directly from your command line.

#php -r 'echo file_get_contents("https://packagist.org/packages.json");'

Last one is to update openssl to the latest version or update XAMPP if you don't have the latest version.

http://windows.php.net/download/
http://indy.fulgan.com/SSL/