In my app developed with Symfony 4.2 and API Platform,
I install DoctrineExtensions bundle to use Loggable extension,
and I follow instructions in Symfony documentation and Loggable extension.
When I only use one EntityManager, everything works.
But I wanna move the LogEntry entity table to another database.
So I created a second EntityManager as described in the Symfony doc.
After, I modify in my app an entity that has the annotation @Gedmo\Loggable
and I get this error:
The class 'Gedmo\Loggable\Entity\LogEntry' was not found in the chain configured namespaces 'App\Entity'
.
My config/packages/doctrine.yaml
file:
parameters:
env(DATABASE_URL): ''
doctrine:
dbal:
connections:
default:
driver: 'pdo_mysql'
server_version: '%env(resolve:SERVER_VERSION)%'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:DATABASE_URL)%'
log:
driver: 'pdo_mysql'
server_version: '%env(resolve:SERVER_VERSION)%'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:LOG_DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
entity_managers:
default:
naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
log:
naming_strategy: doctrine.orm.naming_strategy.underscore
connection: log
mappings:
gedmo_loggable:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity'
prefix: 'Gedmo\Loggable\Entity'
alias: GedmoLoggable
Example of Entity that I want to watch:
<?php
namespace App\Entity;
...
use Gedmo\Mapping\Annotation as Gedmo;
...
/**
* @ApiResource
* @Gedmo\Loggable
* @ORM\Table(name="patients")
*/
class Patient
{
/**
* @ORM\Id
* @ORM\Column(type="guid", unique=true)
* @ORM\GeneratedValue(strategy="UUID")
* @Assert\Uuid
*/
private $id;
/**
* @ORM\Column(length=50)
* @Assert\NotBlank()
* @Assert\Length(max=50)
* @Gedmo\Versioned
*/
public $familyName;
/**
* @ORM\Column(length=50)
* @Assert\NotBlank()
* @Assert\Length(max=50)
* @Gedmo\Versioned
*/
public $firstName;
...
}
I tried to add and remove some properties in the doctrine.yaml
but I always get the same error...
Thanks for your time.