0

I want to use revisions on my entities. I am using Symfony 6 with Doctrine ORM. Doctrine is configured to use MSSQL and works just fine with other entities not using Gedmo - it is tested and it works.

But when I try to add Gedmo Loggable, like this:

composer require gedmo/doctrine-extensions
....
Using version ^3.11 for gedmo/doctrine-extensions

Or this:

composer require stof/doctrine-extensions-bundle
...
behat/transliterator (v1.5.0)
gedmo/doctrine-extensions (v3.11.1)
stof/doctrine-extensions-bundle (v1.7.1)

I add my mapping to my ORM which uses MSSQL:

            gedmo_loggable:
                type: annotation
                prefix: Gedmo\Loggable
                dir: "%kernel.project_dir%/vendor/gedmo/doctrine-extensions/src/Loggable"
                alias: GedmoLoggable
                is_bundle: false

Then i run

php bin/console make:migration

Error:

[critical] Error thrown while running command "make:migration". Message: "Class "Doctrine\ODM\MongoDB\Repository\DocumentRepository" not found"

In LogEntryRepository.php line 24:

  Attempted to load class "DocumentRepository" from namespace "Doctrine\ODM\MongoDB\Repository".
  Did you forget a "use" statement for another namespace?

Is it even possible to use Gedmo without MongoDB? How? I am confused as I cannot find any mention about it being for Mongo solely... And I also recall using it few years back. Has something changed?

Ari Veiene
  • 23
  • 2
  • hmn, maybe try to use annotations or attributes like said in the docs https://github.com/doctrine-extensions/DoctrineExtensions/blob/main/doc/loggable.md – john Smith May 02 '23 at 07:28
  • I am using attributes and I have read the docs. I get the error on cache clear command. It makes sense if Gedmo is required to use MongoDB, but I have not found anything about required DB in docs. For now, I have switched to different auditing library. But I would like to know if it is possible to make Gedmo work with MSSQL. – Ari Veiene May 02 '23 at 07:35
  • i can just confirm that the docs states you can either use ORM or ODM(mongodb), do you have `doctrine/orm` installed? – john Smith May 02 '23 at 07:41

1 Answers1

0

The error is in the directory item, you should add the folder "/Entity " :

gedmo_loggable:
    type: annotation
    prefix: Gedmo\Loggable
    dir: "%kernel.project_dir%/vendor/gedmo/doctrine-extensions/src/Loggable/Entity"
    alias: GedmoLoggable
    is_bundle: false
  • Thank you, I had that in my config. But the problem is something else - Gedmo is registered and is loading. But it *requires* MongoDB, as you can see from the namespace import, which is missing:Message: "Class "Doctrine\ODM\MongoDB\Repository\DocumentRepository" not found" My question was if it it possible to use Gedmo *without MongoDB*, and if so, how. As I am using a different database engine. – Ari Veiene May 04 '23 at 07:42
  • For my part I use a connection to a MariaDB server and it works without problem since everything goes through doctrine – Pierre CAUSSE May 05 '23 at 13:50