I'm trying to use a yml file to map the Id property to Symfony\Component\Ulid.
This is my yml file:
App\Entity\User: type: entity repositoryClass: App\Entity\UserRepository table: user id: id: type: ulid unique: true generator: strategy: CUSTOM class: Symfony\Component\Uid\Ulid
When I run the command to generate "migrations" I get the following error: "Cannot instantiate custom generator, no class defined"
How to use yml file to map Id attribute to Ulid type?
The following mapping using PHP 8 attributes is valid:
namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Uid\Ulid; class User { #[ORM\Id] #[ORM\Column(type: 'ulid', unique: true)] #[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\CustomIdGenerator(class: 'doctrine.ulid_generator')] private $id; public function getId(): ?Ulid { return $this->id; } }
But I need to use yml mapping.
My solution is as follows: