Skip to content

Faker/ORM/Doctrine not working with latest doctrine implementations #413

@icanhazstring

Description

@icanhazstring

Summary

The current version of faker uses the following classes of Doctrine

  • Doctrine\Common\Persistence\ObjectManager
  • Doctrine\Common\Persistence\Mapping\ClassMetadata

As seen here:
https://github.com/FakerPHP/Faker/tree/main/src/Faker/ORM/Doctrine

doctrine/persistence with version 1.3 moved the classes around.
With version 2.0 these aliases were gone, this is when faker will stop working.

We have two options here:

  1. Release a fix adding a simple alias (same as doctrine/persistence https://github.com/doctrine/persistence/blob/1.3.x/lib/Doctrine/Common/Persistence/ObjectManager.php)
  2. Add a conflict in composer.json to avoid installing with doctrine/persistence below ^2.0 and use the new classes.

Versions

Version
PHP 7.4.x
fakerphp/faker latest

Current quickfix

To quickly work around this issue I added these two lines into my tests/bootstrap.php

class_alias(\Doctrine\Persistence\ObjectManager::class, 'Doctrine\Common\Persistence\ObjectManager');
class_alias(\Doctrine\ORM\Mapping\ClassMetadata::class, 'Doctrine\Common\Persistence\Mapping\ClassMetadata');

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions