-
-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ERROR] Only attribute mapping is supported by make:entity, but the <info>App\Entity\User</info> class uses a different format. If you would like this command to generate the properties & getter/setter methods, add your mapping configuration, and then re-run this command with the <info>--regenerate</info> flag. #1152
Comments
`doctrine:
when@test: when@prod:
` |
I recently ran into this problem as well and was a bit baffled as to what had changed. It looks like annotation support was intentionally removed in v1.44 in favor of PHP 8's native support for metadata using attributes: https://github.com/symfony/maker-bundle/blob/v1.44.0/CHANGELOG.md (see #1126) The current Symfony documentation still shows annotations as being supported by MakerBundle, which just adds to the confusion: https://symfony.com/doc/current/doctrine.html#creating-an-entity-class (for example) I can confirm that this particular feature still works in v1.43. So if you still need annotation support with this bundle, you can limit your dev dependency to <=1.43 and that'll hopefully do the trick. Make sure to run https://www.doctrine-project.org/projects/doctrine-orm/en/2.11/reference/attributes-reference.html |
Thank you @NeuralClone But I Will need to use attribute in the future, |
Edit: After playing with this some more, it looks like you'll need a custom mapping driver if you want to use both annotations and attributes at the same time: -- You're welcome, @cmukanisa! It seems that everything is headed toward attribute mapping since that's where PHP is at. Symfony is replacing annotations with the PHP approach and Doctrine has been steadily moving that way too. The syntax for attribute mapping is very similar to annotation mapping. Doctrine's syntax in particular is almost identical to annotations. So it may not be as bad as it seems on the surface. Rector might be worth a look for converting your existing model over to using attribute mapping. |
The error is caused by the use of I highly recommend using |
…ker-bundle (jrushlow) This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Doctrine] show attributes instead of annotations for maker-bundle Starting w/ v1.44.0 - maker bundle only supports attribute mapping w/ entities. Related to symfony/maker-bundle#1152 Commits ------- 50ddde9 [Doctrine] show attributes instead of annotations for maker-bundle
What's expected from users of PHP 7 and Symfony 5.4 ? They'll have to manually downgrade to v1.43 and figure out why the docs mention something that isn't compatible with PHP 7 ? Symfony 5.4 LTS is supposed to "Requires: PHP 7.2.5 or higher" https://symfony.com/releases/5.4 Heading too fast without a standard dependency on version 1.43 for Symfony 5.4 will render things difficult for existing users on LTS. Yes, they should prepare for upgrade to PHP 8 some day... but upgrades on LTS should be flawless IMHP |
Versions higher than 1.43 require PHP 8.0 in |
Right, maybe users of PHP 7 are fine, then the issue is with Symfony 5.4 and users of PHP 8 then. See numerous reports like #841 or https://stackoverflow.com/questions/73073080/symfony-5-only-attribute-mapping-is-supported-by-makeentity |
The maker bundle stopped supporting annotations. Supporting multiple formats causes significant complexity and overhead in the maintenance of this bundle. Every application using PHP 8 is recommended to use attributes and PHP 7 has reached end-of-life, so it makes sense to drop support. If you need annotation support, you can stick to using version 1.43. Maybe the error message can be upgraded to say this, but other than that I think the message is already quite clear. |
Well, too bad for LTS... on the other hand, maintaining multiple branches is a pain, I know. |
I had same problem and solved by adding type field with attribute value like this
|
As @kakhavk mentioned as well. I still had a "type: annotation" configured in my doctrine configuration. You just have to remove that line or change it to "type: attribute" to set it to use attributes instead
|
I hear your arguments about maintenance of the bundle, PHP 8 support and all. But simply bumping the major version of the bundle to 2.0.0 would have avoided a lot of headaches. |
Just removing it didn't solve the problem, I had to inform "attribute" in type. |
[ERROR] Only attribute mapping is supported by make:entity, but the App\Entity\User class uses a different
format. If you would like this command to generate the properties & getter/setter methods, add your mapping
configuration, and then re-run this command with the --regenerate flag.
Today, once I updated my project to the latest version of 5.4.* (5.4.10), I can no longer generate the entities nor can I add to those that already exist
The text was updated successfully, but these errors were encountered: