Skip to content
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

Symfony Doctrine bridge needs Doctrine ORM but it is not mandatory dependency #37045

Closed
arnolanglade opened this issue Jun 1, 2020 · 2 comments

Comments

@arnolanglade
Copy link

Symfony version(s) affected: 5.0.9

Description
Symfony Doctrine bridge does not require Doctrine DBAL nor Doctrine ORM but they are only "suggested" (https://packagist.org/packages/symfony/doctrine-bridge). I am working on a project which uses Doctrine DBAL but does not use Doctrine ORM. Since the last patch of Symfony (v5.0.9) we had to hard code the version doctrine bridge to v5.0.8 to avoid errors (described in the next section).

How to reproduce

  • Install Symfony project with DoctrineBundle and Doctrine DBAL but without Doctrine ORM.
  • Run bin/console doctrine:database:drop --force
  • Then you get the error: Attempted to load class "ToolEvents" from namespace "Doctrine\ORM\Tools". Did you forget a "use" statement for another namespace?

Additional context

The problem comes from https://github.com/symfony/doctrine-bridge/blob/master/SchemaListener/MessengerTransportDoctrineSchemaSubscriber.php#L93. This class uses Doctrine ORM and DBAL events. Should we move those libraries from "suggested" to "required"?

{
   "message":"Command \"doctrine:database:drop --force\" exited with code \"1\"",
   "context":{
      "command":"doctrine:database:drop --force",
      "code":1
   },
   "level":100,
   "level_name":"DEBUG",
   "channel":"console",
   "datetime":"2020-06-01T14:53:25.165344+00:00",
   "extra":{

   }
}{
   "message":"Uncaught Error: Class 'Doctrine\\ORM\\Tools\\ToolEvents' not found",
   "context":{
      "exception":{
         "class":"Error",
         "message":"Class 'Doctrine\\ORM\\Tools\\ToolEvents' not found",
         "code":0,
         "file":"/path/to/vendor/symfony/doctrine-bridge/SchemaListener/MessengerTransportDoctrineSchemaSubscriber.php:93"
      }
   },
   "level":500,
   "level_name":"CRITICAL",
   "channel":"php",
}
@arnolanglade arnolanglade changed the title Symfony Doctrine bridge needs to Doctrine ORM but it is not required library Symfony Doctrine bridge needs Doctrine ORM but it is not mandatory dependency Jun 1, 2020
@xabbuh
Copy link
Member

xabbuh commented Jun 2, 2020

Can you confirm that #37056 fixes the issue you experience?

@fabpot fabpot closed this as completed Jun 2, 2020
fabpot added a commit that referenced this issue Jun 2, 2020
… installed packages (xabbuh)

This PR was merged into the 5.1 branch.

Discussion
----------

[DoctrineBridge] register event listeners depending on the installed packages

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #37045
| License       | MIT
| Doc PR        |

Commits
-------

f61b009 register event listeners depending on the installed packages
@arnolanglade
Copy link
Author

Yes it works, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants