0
votes

I did a fresh install of wampserver 2.5 64bit on windows 7 64bit with php 5.5.12. After that, I appendend php path to the window's PATH environment variable.

Then i installed composer using the installer found at the official site.

When i try to run any command, i get a host error, for example:

composer create-project --prefer-dist -s dev SOMEPACKAGE

[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: php_network_getaddresses: getaddrinfo failed: Host sconosciuto. failed to open stream: php_network_getaddresses: getaddrinfo failed: Host sconosciuto.

composer diagnose

Checking platform settings: FAIL The xdebug extension is loaded, this can slow down Composer a little. Disabling it when using Composer is recommended, but should not cause issues beyond slowness. Checking git settings: OK Checking http connectivity: FAIL [Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: php_network_getaddresses: getaddrinfo failed: Host sconosciuto. failed to open stream: php_network_getaddresses: getaddrinfo failed: Host sconosciuto. Checking disk free space: OK

Host sconosciuto means "Host not known" Did someone know how can i get composer work? I'm not behind a proxy and my hosts file only has one record: 127.0.0.1 localhost

Thank you

1

1 Answers

0
votes

It sounds like you have not activated opensssl.dll and php_curl in the php.ini that is used by the PHP CLI ( Command line interface )

In Wampserver there are 2 php.ini files, one used by Apche and one used by PHP when run from the command line.

Check \wamp\bin\php\php5.5.12\php.ini and make sure all the extensions you will need to use with Composer are activated, php_openssl is definitely one of them php_curl is another.

Also with WAMPServer it is bad practice to put the folder with the PHP executable on the Windows PATH environmant variable, as with WAMPServer you can switch versions of PHP easily.

I use this batch file

FILENAME = phppath.cmd

echo off
if %1.==. GOTO DEFAULT
ECHO ----------Setting up PHP%1---------------------------------
PATH=%PATH%;d:\wamp\bin\php\php%1
php -v
GOTO COMPOSER

:DEFAULT
echo Taking the default version php5.5.12
echo ----------DEFAULT----------------------------------------------
PATH=%PATH%;d:\wamp\bin\php\php5.5.12
php -v

:COMPOSER
echo Make Composer work
PATH=%PATH%;D:\wamp\composer
echo ---------------------------------------------------------------

Instead of adding php to the Windows PATH put this file in a folder that is already on your path, C:\windows if you dont have any of your own already on the PATH.

To put the default PHP version of the path just call it like :-

>phppath

To add a specific PHP version ( assuming you have more than one installed into WAMPServer call it like :-

>phppath 5.5.14

ADDITIONAL INFO

update: in cli i can't even connect to database in localhost

Then your 2 ini files are not the same or you are loading one from somewhere else.

Do this from a command window

php --ini

It should look like this

Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File:         C:\wamp\bin\php\php5.5.12\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

So check you dont have a rouge php.ini in the C:\windows folder, or anywhere else that may show up in the list. The php.ini should only be in C:\wamp\bin\php\php5.5.12\php.ini