NelmioApiDocBundle: Incompatibility with DoctrineBundle v2.8

Hi,

When I upgraded the doctrine/doctrine-bundle from 2.7 to 2.8, the NelmioApiDocBundle stopped to work:

    The service "nelmio_api_doc.model_describers.object" has a dependency on a
    non-existent service "annotations.reader".

Looks like the doctrine/doctrine-bundle moved their dependency on doctrine/annotations from the required to require-dev section, starting from version 2.8.0.

Any advice, workaround, or maybe a new version of this great bundle which will work with the recent DoctrineBundle, please? 😃

P.S. The NelmioApiDocBundle is great, btw. Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 16 (5 by maintainers)

Most upvoted comments

doctrine/annotations will be optional soon in swagger-php: https://github.com/zircote/swagger-php/pull/1508

@DjordyKoert Oh, I see that there is multiple new releases today - I’ll try to upgrade that bundle and see what happens - thanks!

I’m having the same issue when using NelmioApiDocBundle in prod. Setting framework.annotations.enabled: true solves it for now, but it’s deprecated since Symfony 6.4:

Since symfony/framework-bundle 6.4: Enabling the integration of Doctrine annotations is deprecated. Set the ā€œframework.annotations.enabledā€ config option to false.

Also, NelmioApiDocBundle is indeed great, thank you for the work!

Thanks for the additional details. I think the root cause is that you use NelmioApiDocBundle as a dev dependency, Symfony core moves more and more to enabling features by default only if they are available in prod (the willBeAvailable field in https://github.com/symfony/symfony/blob/c301d9a49a1562b39d8c28eee2b5f4791d51ab14/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php#L971 checks that).

An immediate solution for you is to add framework.annotations: true to your dev config.

Longer term I see either:

  • modify the nelmio recipe and add a file packages/dev/nelmio.yaml enabling the annotations
  • configure the annotations reader manually in NelmioApiDocBundle

I prefer just modifying the recipe personally although that’s possibly bothering for people also using NelmioApiDocBundle as a dev dependency and that will have the same issue (because of doctrine-bundle or another dependency) until they upgrade to the new recipe…

P.S. The NelmioApiDocBundle is great, btw. Thanks!

Thank you ā¤ļø

When I upgraded the doctrine/doctrine-bundle from 2.7 to 2.8, the NelmioApiDocBundle stopped to work:

I don’t really understand the root cause here, zircote/swagger-php still has a dependency on doctrine/annotations so it should still work fine.

Which version of NelmioApiDocBundle are you using? Is it v3.x? Are you activating annotations in your framework bundle config? (i.e. framework.annotations: true)

If not too sensitive, having your composer.lock (maybe without the private packages if you use any) could help pinpoint the root issue.

I have the same issue, but for other reason. This is the only package from my dependencies, that forces the download of v1 branch of doctrine/annotations and this has other side-effects. And, yeah, NelmioApiDocBundle is great 😃.

Unfortunately that’s a hard dependency as we use the annotations from zircote/swagger-php as models. Unless they remove the dependency in their bundle first, it would be a too big investment to remote this dependency here.

The latest version solved it for me as well, thank you!

I think upgrading the recipe is a fine solution. Meanwhile, those who use NelmioApiDocBundle as a dev dependency can update framework.annotations until new version is released.

Thank you for your help!