Home > Software design >  To use Doctrine entity attributes you'll need PHP 8, doctrine/orm 2.9, doctrine/doctrine-bundle
To use Doctrine entity attributes you'll need PHP 8, doctrine/orm 2.9, doctrine/doctrine-bundle

Time:02-11

I have a problem on my symfony project version 4.4.9, when i type php bin/console make:entity this errors it display to me

To use Doctrine entity attributes you'll need PHP 8, doctrine/orm 2.9, doctrine/doctrine-bundle 2.4 and symfony/framework-bundle 5.2.

composer.json

    "php": ">=7.1.3",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "doctrine/annotations": "^1.13",
    "doctrine/doctrine-bundle": "^2.5",
    "doctrine/doctrine-migrations-bundle": "^3.2",
    "doctrine/orm": "2.9.6",
    "symfony/console": "4.4.*",
    "symfony/dotenv": "4.4.*",
    "symfony/flex": "^1.3.1",
    "symfony/framework-bundle": "4.4.*",
    "symfony/proxy-manager-bridge": "4.4.*",
    "symfony/yaml": "4.4.*"
},

and my PHP Version : 8.1  The error

CodePudding user response:

Seems to be an issue running Symfony 4.4 Symfony Maker Bundle under under PHP 8 .

I can reproduce the issue with a project created from scratch on PHP 8.

$ composer create-project symfony/skeleton maker-annotations ^4.4.0
$ cd maker-annotations
$ composer require doctrine symfony/maker-bundle
$ bin/console make:entity

This will consistently error out under PHP8. Funnily enough, you can call make:entity again over the same entity, and it will appear to work... but it will error out for some other reason in the end.

The only solution I could find was to downgrade PHP to 7.4. If you are using a version of Symfony that old, it might be safer to use an older version of PHP as well in any case.

Or better yet, simply upgrade your Symfony version to 5.2.

  • Related