maker-bundle icon indicating copy to clipboard operation
maker-bundle copied to clipboard

[ERROR] Only annotation mapping is supported by make:entity after upgrading bundles

Open thomas2411 opened this issue 5 years ago • 31 comments

After upgrading bundles like this:

Upgrading doctrine/doctrine-bundle (2.2.3 => 2.3.0)
Upgrading doctrine/migrations (3.1.0 => 3.1.1)
Upgrading symfony/doctrine-bridge (v5.2.4 => v5.2.5)
Upgrading symfony/maker-bundle (v1.29.1 => v1.30.0)  

when I try to change or add a new entity like:

php bin/console make:entity MyEntity I get error

Only annotation mapping is supported by make:entity, but the <info>App\Entity\MyEntity</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. 

When I have downgraded to previous version it works OK.

thomas2411 avatar Mar 20 '21 15:03 thomas2411

Same problem here:

- Upgrading doctrine/doctrine-bundle (2.2.4 => 2.3.0)
- Upgrading symfony/maker-bundle (v1.29.1 => v1.30.0)

After downgrading doctrine/doctrine-bundle to 2.2.4 maker works fine...

cpoint-eu avatar Mar 20 '21 15:03 cpoint-eu

The getMetadataDriverImpl method returns different things in the two versions.

In v2.2.4 it returns Doctrine\Persistence\Mapping\Driver\MappingDriverChain In v2.3.0 it returns Doctrine\Bundle\DoctrineBundle\Mapping\MappingDriver

https://github.com/symfony/maker-bundle/blob/main/src/Doctrine/DoctrineHelper.php#L98-L110

connorhu avatar Mar 20 '21 16:03 connorhu

Same problem with v1.30.0

bechir avatar Mar 21 '21 01:03 bechir

Same problem with clean project:

doctrine/doctrine-bundle 2.3.0
symfony/maker-bundle 1.30.0

Work fine with doctrine/doctrine-bundle 2.2.4 and symfony/maker-bundle 1.30.0

dcognata avatar Mar 21 '21 10:03 dcognata

Found problem and fix. PR 1284 in DoctrineBundle added a new MappingDriver, that adds a new step to access the MappingDriverChain from the MakeEntity command. I'm doing a PR right now.

Geekimo avatar Mar 21 '21 21:03 Geekimo

Just pushed PR #843 to fix this issue, but will need #1304 from doctrine bundle to be merged.

Geekimo avatar Mar 21 '21 21:03 Geekimo

Fixed now in 1.30.1 :)

weaverryan avatar Mar 22 '21 17:03 weaverryan

I'm still having the same issue even with 1.31.0. my PHP version is 8 if that makes any difference

abul-wcse avatar May 05 '21 21:05 abul-wcse

I can confirm that 1.30.2 has fixed the problem (PHP 7.4)

dsentker avatar May 11 '21 10:05 dsentker

@abul-wcse Can you create a simple Symfony App that reproduces this problem?

jrushlow avatar May 11 '21 15:05 jrushlow

steps to reproduce

  • symfony new --dir=~/Working/personal/maker-test --no-git --full
  • cd symfony-test
  • Replace the App in name to Custom
  • Update the PSR4 settings in composer.json
  • composer dump-autoload
  • create a new file in the config/package directory called maker.yaml and add
maker:
  root_namespace: 'Custom'
  • bin/console make:entity NewEntity I get the following error Screenshot 2021-05-11 at 5 07 35 pm

Here is the simple Symfony app created using the above steps @jrushlow https://github.com/abul-wcse/maker-test

abul-wcse avatar May 11 '21 16:05 abul-wcse

Still having the same issue. v1.33.0

javlonbek-sharipov avatar Aug 04 '21 21:08 javlonbek-sharipov

We still have the issue with latest symfony version and doctrine version. When using PHP 8 attributes for doctrine, we can not use the maker to add/modify entity

bastien70 avatar Aug 06 '21 09:08 bastien70

Same issue on 1.36 with PHP 8 attributes for doctrine.

reksc avatar Dec 03 '21 13:12 reksc

Same issue on 1.38 with PHP 8.1 with custom root_namespace.

planet17 avatar Mar 09 '22 23:03 planet17

Problem reappeared. I have just upgraded all bundles and with version 1.38 error appears again (PHP 8.1). Tweaking a little bit with versions showed that the reason is upgrading doctrine/orm (2.11.3 => 2.12.0)

thomas2411 avatar Apr 21 '22 12:04 thomas2411

I'm using PHP 8.1 and after upgrading to 1.44 this bug reappeared for me again. Downgrading to 1.43 fixed it.

ShiNoSenshi avatar Jul 22 '22 07:07 ShiNoSenshi

Are u using attributes for you're entity mapping?

jrushlow avatar Jul 22 '22 07:07 jrushlow

I debugged into the error message and found out, that it uses AnnotationDriver instead of the expected AttributeDriver. Can you tell me where in my config I have to change the setting?

ShiNoSenshi avatar Jul 22 '22 08:07 ShiNoSenshi

I'm using PHP 8.1 and after upgrading to 1.44 this bug reappeared for me again. Downgrading to 1.43 fixed it.

Thanks, works for me ! :-)

UtechtDustin avatar Jul 22 '22 09:07 UtechtDustin