Symfony CLI does not use the correct PHP version when running the "new" command

1.8k views Asked by At

I have setup my environment as follows: Wamp 3 with PHP7.1.33 version, composer 2 and the Symfony binary.

But when I try to run symfony new my_project_name --version=4.4 --full I get this error:

Creating a "symfony/website-skeleton" project at "./my_project_name" Your version of PHP, 5.4.12, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade. [InvalidArgumentException] Could not find package symfony/website-skeleton with version 4.4.* in a version installable using your PHP version, PHP extensions and Composer version.

As mentionned in the error, PHP 5.4.12 is used, but when I run php --version I get 7.1.33 version.

1

There are 1 answers

0
yivi On

I haven't used either WAMP or the Symfony binary, but on the documentation it says:

If you have multiple PHP versions installed on your computer, you can tell Symfony which one to use creating a file called .php-version at the project root directory

If you have multiple PHP versions installed, apparently the tool attempts to find them and list them if you use the symfony local:php:list command. No idea how it works or how reliable it is, but should tell you if it's able to detect your PHP 7 runtime.

More importantly, despite the poor advice on Symfony part, you do not really need to use the symfony binary to create a project. The binary simply calls composer, so why not call composer directly? That way you can be sure you are using the PHP and Composer's versions you want and expect, instead of relying on an intermediary.

Just do:

composer create-project symfony/website-skeleton your-project-name ^4.4

(this is what you get by using the --full flag, if you do not use it you simply install symfony/skeleton, which includes less components out of the box).

As an aside, naming the binary symfony was a really poor choice on Symfony's part, as it makes it almost impossible to search for issues related to the tool and not the framework. Or to suggest to use the binary instead of using composer directly, adding a layer of opacity for many users.