KnpLabs / DoctrineBehaviors

Doctrine2 behavior traits that help handling Blameable, Loggable, Sluggable, SoftDeletable, Uuidable, Timestampable, Translatable, Tree behavior
http://knplabs.com
MIT License
911 stars 287 forks source link

Error when installing DoctrineBehaviors in a fresh Symfony install #598

Closed flambies closed 2 years ago

flambies commented 3 years ago

When I'm trying to install DoctrineBehaviors in a fresh symfony 5 install, i get an autowiring error:

In DefinitionErrorExceptionPass.php line 54: Cannot autowire service "Knp\DoctrineBehaviors\Provider\UserProvider": argu !! ment "$security" of method "__construct()" references class "Symfony\Compon !! ent\Security\Core\Security" but no such service exists.

I could fix this by installing the composer require symfony/security-bundle. I think there might be a missing package in the composer.json or update to the Symfony Security-Core.

Here the full installation :

**~composer require knplabs/doctrine-behaviors**
Using version ^2.0 for knplabs/doctrine-behaviors
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "5.1.*"

Prefetching 8 packages 🎶 💨
  - Downloading (100%)

Package operations: 8 installs, 0 updates, 0 removals
  - Installing ramsey/collection (1.1.1): Loading from cache
  - Installing brick/math (0.9.1): Loading from cache
  - Installing ramsey/uuid (4.1.1): Loading from cache
  - Installing nette/utils (v3.1.3): Loading from cache
  - Installing nette/finder (v2.5.2): Loading from cache
  - Installing symplify/package-builder (8.3.17): Loading from cache
  - Installing symfony/security-core (v5.1.6): Loading from cache
  - Installing knplabs/doctrine-behaviors (v2.0.7): Loading from cache
Writing lock file
Generating optimized autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
60 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Symfony operations: 1 recipe (832af8450345f4cf51605936782dca41)
  - Configuring knplabs/doctrine-behaviors (>=v2.0.7): From auto-generated recipe
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!  
!!  In DefinitionErrorExceptionPass.php line 54:
!!                                                                                 
!!    Cannot autowire service "Knp\DoctrineBehaviors\Provider\UserProvider": argu  
!!    ment "$security" of method "__construct()" references class "Symfony\Compon  
!!    ent\Security\Core\Security" but no such service exists.                      
!!                                                                                 
!!  
!!  
Script @auto-scripts was called via post-update-cmd

Installation failed, reverting ./composer.json to its original content.
TimurFlush commented 3 years ago

You need to require the symfony/security-bundle package before it

TomasVotruba commented 2 years ago

Closing as resolved

MatTheCat commented 2 years ago

This is not resolved: I shouldn’t have to require symfony/security-bundle to use the translatable behavior. Services should be conditionally defined.

TomasVotruba commented 2 years ago

Feel free to send PR with improvement.