3

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.

yivi
  • 42,438
  • 18
  • 116
  • 138
zackzulg
  • 599
  • 2
  • 5
  • 21
  • 3
    Does this answer your question? [How to change PHP version used by composer](https://stackoverflow.com/questions/46986139/how-to-change-php-version-used-by-composer) – Nico Haase May 21 '21 at 14:26
  • I assume you mean WAMPServer. If you have PHP7.1.33 (note you can upgrade that to PHP 8 if you like quite easily or any version between) that does not means that that version os being used by the PHP CLI See this answer to see hwo to get a terminal to use whatever version of PHP you want it to https://stackoverflow.com/questions/15597067/how-to-run-php-from-windows-command-line-in-wampserver/16289254#16289254 – RiggsFolly May 21 '21 at 14:38
  • @NicoHaase Yes thank you !! I guess php stills point to an old version of wamp even if I set Environment variables. I had to replace php5.4.12 folder in my old wamp with php7.1.33 and it works for me. – zackzulg May 21 '21 at 15:25

1 Answers1

5

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.

yivi
  • 42,438
  • 18
  • 116
  • 138