1
votes

I'm working on a Symfony (4.4) project with PHP version(7.1.30) and now I want to start a new Symfony (5.0/5.1) project.

But I could not do it because it wants at least PHP 7.2.5. (Windows 10 machine).

I have installed PHP 7.3.6 and added it to the PATH environment. But when I try to create the new Symfony project I get this error:

Your requirements could not be resolved to an installable set of packages.

Problem 1 - symfony/symfony v5.0.2 requires php ^7.2.5 -> your PHP version (7.1.30) does not satisfy that requirement. - symfony/symfony v5.0.1 requires php ^7.2.5 -> your PHP version (7.1.30) does not satisfy that requirement. - symfony/symfony v5.0.0 requires php ^7.2.5 -> your PHP version (7.1.30) does not satisfy that requirement. - Installation request for symfony/symfony ^5.0 -> satisfiable by symfony/symfony[v5.0.0, v5.0.1, v5.0.2].

Can you please advise how can I use 2 different PHP versions for the different projects?

(I can't upgrade the 'old' project because some extensions cannot work with 7.2.5)

2
run all commands like bin/console etc. with the correct php cli versionLBA
I just installed the new project with composer, and the error is on composer updateSashoSTZ
Hi @SashoSTZ, do you know about docker or virtualbox to create machines ad hoc for your projects? Maybe it could be hard for you to start using it, but it could help you A LOT in the future when machine configuration is required.Federico J.

2 Answers

1
votes

To run composer with an older php version, download an appropriate phar of composer for that version. The latest is probably compatible with all versions, but if it doesn't work download an earlier version until it starts working.

Then run the non default php with the following command in the composer.phar directory(replace C:\php7.2.5 with your actual path):

C:\php7.2.5\php.exe -c C:\php7.2.5\php.ini composer.phar update

If you use git bash(what I do)

/c/php7.2.5/php.exe -c /c/php7.2.5/php.ini composer.phar update

You can also make this into a batch or bat file pretty easy.

The -c flag is to point to the correct php.ini.

0
votes

You can select the php version for the project with

echo 7.4.10 > .php-version

When you create the .php-version for each project you can run the server as you run it usually and everything works fine

Also, when I use 7.4.10 locally, I have to use my commands like this

symfony php bin/console make:migration

with symfony before php bin/console