Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sgupta1979's avatar

Upgrading PHP 7.4 to 8.1 with symfony 3.4

Hello Team,

On my local environment, I am upgrading PHP version from 7.4.26 to 8.1.20 I am not upgrading my Symfony version which is 3.4 currently.

I am getting lots of conflicts with packages version. My composer packages are as below.

"require": { "artgris/maintenance-bundle": "^1.0", "cam/client": "2.", "doctrine/doctrine-bundle": "^1.12", "doctrine/doctrine-migrations-bundle": "^2.1", "doctrine/orm": "^2.7", "ext-curl": "", "ext-json": "", "ijanki/doctrine-mysql-dbal-extensions": "^1.0", "jms/serializer-bundle": "^2.4", "knplabs/knp-menu-bundle": "^2.3", "myclabs/deep-copy": "^1.9", "php": "7.4.", "phpoffice/phpspreadsheet": "^1.11", "predis/predis": "^1.1", "sensio/distribution-bundle": "^5.0", "sensio/framework-extra-bundle": "^3.0", "symfony/dotenv": "^3.4", "symfony/filesystem": "^3.4", "symfony/monolog-bundle": "^3.5", "symfony/property-access": "^3.4", "symfony/swiftmailer-bundle": "^2.6", "symfony/symfony": "3.4.*" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "^2.4", "friendsofphp/php-cs-fixer": "^2.16", "roave/security-advisories": "dev-latest", "sensio/generator-bundle": "~3.1", "symfony/browser-kit": "^3.4", "symfony/css-selector": "^3.4", "symfony/phpunit-bridge": "^4.4" },

Kindly suggest me requried changes.

0 likes
6 replies
LaryAI's avatar
Level 58

To upgrade PHP from version 7.4 to 8.1 while keeping Symfony version 3.4, you will need to make the following changes to your composer.json file:

  1. Update the PHP version in the "require" section to "8.1.*":
"require": {
    ...
    "php": "8.1.*",
    ...
},
  1. Check the compatibility of each package with PHP 8.1. You can use the Symfony Compatibility Checker tool to verify if your packages are compatible. If any of the packages are not compatible, you will need to find alternative packages or update them to their latest versions that support PHP 8.1.

  2. Update the packages that have new versions compatible with PHP 8.1. For example, the "doctrine/doctrine-bundle" package can be updated to version "^2.4" to support PHP 8.1:

"require": {
    ...
    "doctrine/doctrine-bundle": "^2.4",
    ...
},
  1. Run composer update to update the packages and resolve any conflicts. This will update the packages to their latest compatible versions with PHP 8.1.

  2. After updating the packages, make sure to test your application thoroughly to ensure that everything is working as expected.

Note: It's always recommended to have a backup of your project before making any major changes like upgrading PHP versions.

sgupta1979's avatar

I tried with composer updates, getting below conflicts. Please suggest comptible packages for these. PHP : 8.1 and Symfony 3.4

Problem 1

- Root composer.json requires cam/client 2.* -> satisfiable by cam/client[2.0.0, ..., 2.0.7].

- cam/client[2.0.0, ..., 2.0.7] require php 7.4.* -> your php version (8.1; overridden via config.platform, actual: 8.1.20) does not satisfy that requirement.

Problem 2

- Root composer.json requires jms/serializer-bundle ^2.4 -> satisfiable by jms/serializer-bundle[2.4.0, ..., 2.4.4].

- jms/serializer-bundle[2.4.0, ..., 2.4.4] require php ^5.4|^7.0 -> your php version (8.1; overridden via config.platform, actual: 8.1.20) does not satisfy that requirement.

Problem 3 - Root composer.json requires knplabs/knp-menu-bundle ^2.3 -> satisfiable by knplabs/knp-menu-bundle[v2.3.0].

- knplabs/knp-menu-bundle v2.3.0 requires php ^7.1 -> your php version (8.1; overridden via config.platform, actual: 8.1.20) does not satisfy that requirement.

Problem 4 - Root composer.json requires doctrine/doctrine-fixtures-bundle ^2.4 -> satisfiable by doctrine/doctrine-fixtures-bundle[v2.4.0, v2.4.1].

- doctrine/doctrine-fixtures-bundle[v2.4.0, ..., v2.4.1] require doctrine/doctrine-bundle ~1.0 -> found doctrine/doctrine-bundle[v1.0.0, ..., 1.12.13] but it conflicts with your root composer.json require (^2.4).

Problem 5

- doctrine/migrations[2.3.2, ..., 2.3.5] require friendsofphp/proxy-manager-lts ^1.0 -> satisfiable by friendsofphp/proxy-manager-lts[v1.0.0, ..., v1.0.16].

- doctrine/doctrine-migrations-bundle[2.1.0, ..., 2.2.1] require php ^7.1 -> your php version (8.1; overridden via config.platform, actual: 8.1.20) does not satisfy that requirement.

- doctrine/migrations[2.2.0, ..., 2.3.1] require php ^7.1 -> your php version (8.1; overridden via config.platform, actual: 8.1.20) does not satisfy that requirement.

- friendsofphp/proxy-manager-lts[v1.0.0, ..., v1.0.3] require symfony/filesystem ^4.4.17|^5.0 -> found symfony/filesystem[v4.4.17, ..., v4.4.42, v5.0.0, ..., v5.4.25] but it conflicts with your root composer.json require (^3.4).

- friendsofphp/proxy-manager-lts[v1.0.4, ..., v1.0.15] require symfony/filesystem ^4.4.17|^5.0|^6.0 -> found symfony/filesystem[v4.4.17, ..., v4.4.42, v5.0.0, ..., v5.4.25, v6.0.0, ..., v6.3.1] but it conflicts with your root composer.json require (^3.4).

- friendsofphp/proxy-manager-lts v1.0.16 requires symfony/filesystem ^4.4.17|^5.0|^6.0|^7.0 -> found symfony/filesystem[v4.4.17, ..., v4.4.42, v5.0.0, ..., v5.4.25, v6.0.0, ..., v6.3.1] but it conflicts with your root composer.json require (^3.4).

- doctrine/doctrine-migrations-bundle[2.2.2, ..., 2.2.3] require doctrine/migrations ^2.2 -> satisfiable by doctrine/migrations[2.2.0, ..., 2.3.5].

- Root composer.json requires doctrine/doctrine-migrations-bundle ^2.1 -> satisfiable by doctrine/doctrine-migrations-bundle[2.1.0, ..., 2.2.3].
sgupta1979's avatar

If I will try to upgrade to symfony 4 with PHP 8.1, from symfony 3.4 and PHP 7.4 What will be code level changes and suitable steps to upgrade.

jlrdw's avatar

Check dependency requirements, it is really that simple in my opinion.

sgupta1979's avatar

@jlrdw Do you have any guidelines for this change. Please share web-url if possible. Thanks

jlrdw's avatar

@sgupta1979 you check requirements in the composer.json file.

Edit:

Or documentation. For example laravel clearly states the requirements as does any framework or package.

Please or to participate in this conversation.