Running 2 Symfony projects with different php versions - php

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)

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.

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

Related

Old Laravel project is not working after a while, What can I do to make it running again?

I have an old project and I am not the person that worked on it
I need to run it again but it's giving me this error
This page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500
I tried to run composer update but it gives me this error
Problem 1
- Root composer.json requires php ^7.1.3 but your php version (8.1.5) does not satisfy that requirement.
Problem 2
- laravel/framework[v5.6.0, ..., 5.6.x-dev] require php ^7.1.3 -> your php version (8.1.5) does not satisfy that requirement.
- Root composer.json requires laravel/framework 5.6.* -> satisfiable by laravel/framework[v5.6.0, ..., 5.6.x-dev].
You can do composer install by following command
composer install --ignore-platform-reqs --no-script
Also another way can be to update your composer.json php version to 8 or downgrade your system php version to php7.
Hope it works.

PHP - symfony/console library thorws deprecated error with 8.1

When running my PHP project which is now using version 8.1. I get the error:
PHP Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/XAMPP/xamppfiles/htdocs/project-core/vendor/symfony/console/Helper/HelperSet.php on line 111
Tried:
php composer.phar update vendor/symfony/console
and got the same error.
Also tried:
composer update symfony/console
and I got conflicts like:
Problem 1
- facebook/webdriver is locked to version 1.2.0 and an update of this package was not requested.
- facebook/webdriver 1.2.0 requires php ^5.5 || ~7.0 -> your php version (8.1.4) does not satisfy that requirement.
Problem 2
- cakephp/collection 3.10.1 requires php >=5.6.0,<8.0.0 -> your php version (8.1.4) does not satisfy that requirement.
- robmorgan/phinx 0.10.8 requires cakephp/collection ^3.6 -> satisfiable by cakephp/collection[3.10.1].
- robmorgan/phinx is locked to version 0.10.8 and an update of this package was not requested.
I also checked THIS LINK. Can someone help me figure out this problem?
I have also seen THIS but I do not think it solves the issue as I can not edit vendor files..
It could be that composer itself needs to be updated, rather than the dependencies you are trying to install.
Upgrading composer v2.0.9 to v2.5.0 was the fix I needed to silence deprecation notices mentioning symfony.
Depending on how you installed composer, and whether you've renamed the phar to just composer and put it in your path, that is done with:
php composer.phar self-update
or
composer self-update
Add sudo if permissions require.

laravel/framework v6.9.0 requires php ^7.2

I just finish my laravel project on my local machine, I want to upload to my server to become live api, okay, I searched, youtubed, googled, or etc.. and found some solution for upload, I just upload my whole project, without vendor, and composer.lock, not set database config yet. after upload, I run:
composer install
it give me some error about php version:
Problem 1
- laravel/framework v6.9.0 requires php ^7.2 -> your PHP version (7.1.33) overridden by "config.platform.php" version (5.5.9) does not
satisfy that requirement.
But my php version is:
PHP Version 7.3.13
How can I fix this?
Check your .bash_profile on ~ root and add this lines:
PATH="/usr/local/php73/bin:$PATH" // make sure your path to php73
export PATH
then:
php -v -> reboot -> php -v

Laravel 5.5. and PHP 7

I am updating to Laravel 5.5. which uses PHP 7.0 version. I need to do setup on my local machine and on AWS as well. First, locally WAMP server is installed which comes with PHP 7.0 ... I've selected it and when localhost is opened I get the message that the PHP version is 7.0.10 ... After changing version numbers for Laravel and PHP in composer.json, I did update and got this message:
Problem 1
This package requires php >=7.0 but your PHP version (5.6.25) does not satisfy that requirement. Problem 2
laravel/framework v5.5.2 requires php >=7.0 -> your PHP version (5.6.25) does not satisfy that requirement.
laravel/framework v5.5.1 requires php >=7.0 -> your PHP version (5.6.25) does not satisfy that requirement.
laravel/framework v5.5.0 requires php >=7.0 -> your PHP version (5.6.25) does not satisfy that requirement.
Installation request for laravel/framework 5.5.* -> satisfiable by laravel/framework[v5.5.0, v5.5.1, v5.5.2].
It is written that I still use 5.6. How can I change this?
According to #iainn Apache is using PHP 7, but the CLI (which Composer uses) is still using 5.6 hence, trying to uninstall and install composer again and select the correct php version (7.0) while setup. Check below screenshot
You're getting an error from composer. Try using
'composer install --ignore-platform-reqs'
to setup your project folder.
Just change varible enviroment on your computer
add path php you would you like to use

Issue with installing zendframework2 skeleton

i'm new to zendframework 2 , while trying to install it , using composer , it gets installed but an error message appears saying :
Your requirements could not be resolved to an installable set of packages.
Problem1
- Installation request for zendframework/zendframework 2.3.* -> satisfiable by zendframework/zendframework[2.3.0].
- zendframework/zendframework 2.3.0 requires php >=5.3.23 -> no matching package found
knowing that I have php 5.4.3.
Could someone please explain to me what's wrong ?
thanks in advance
Make sure the PHP version you are using for the CLI is using PHP 5.4.3 too. The CLI version can use a different PHP version than the host. You can get the php version used by the console by using the php --version command.

Categories