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

22.4k Views Asked by At

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"
        ]
    }
}
4

There are 4 best solutions below

9
On BEST ANSWER

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/

0
On

I've encountered this with proxies before. Please check your env vars for HTTP_PROXY_REQUEST_FULLURI to false and that HTTP_PROXY and HTTPS_PROXY are not set to something they can't connect to.

0
On

Few options here I can think of:

  • It is looking for a file https://packagist.org/p/symfony/routing$0b411061e305b2d7a108caca01c21b859b6a2be133eff320b93e64d8c5759e2b.json which clearly doesn't exist. So one option would be to comment out the packages except one, to rule out which one it is. Then try installing a different version for it.

  • Check your PHP version. What is the PHP version you are using? If 5.3, than surely it would
    be fixed by updating to a more recent version. It has some issues
    with SSL.

0
On

If laravel composer is installed and can be accessed globally on your machine but you are getting error in downloading laravel installer then go for following steps:

  1. Open cmd as Administrator.
  2. Run the following command: composer diagnose

Check for following highlighed settings:

C:\Windows\system32>composer diagnose
Checking platform settings: OK
Checking git settings: OK  
**Checking http connectivity to packagist:** OK
**Checking https connectivity to packagist:** WARNING
[Composer\Downloader\TransportException] The "https://packagist.org/packages.jso
n" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error
 messages:
error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Failed to enable crypto
failed to open stream: operation failed
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB
723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E32
8C AD90147D AFE50952
OK
Checking composer version: OK

So, I have an issue of OpenSSL because of my company proxy settings. To resolve go for following steps:

First, make sure with your company IT deptt. that SSL should be enabled on your machine. Then, try again to download laravel installer. If it still does not work; then go further.

Get the path of cacert file (in my case, path is C:\Users\harshita.kumar\AppData\Roaming\Composer).

Open php.ini file and locate openssl.cafile in the file. Uncomment this line by removing ; and give the cacert file path to it.

Check again for laravel installer. It must/ will work now.

I hope this would be helpful.