Uuid on api-platform as Primary Key
dadangnh opened this issue · 2 comments
When we use Uuid as Primary Key on API-Platform Project, it shows:
Can't instantiate custom generator : UuidGenerator in . (which is being imported from "/storage/dadangnh/Projects/djp-iam/config/routes/api_platform.yaml"). Make sure there is a loader supporting the "api_platform" type.
On the entity, $id was like this:
/**
* @var UuidInterface
*
* @ORM\Id()
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\Column(type="uuid", unique=true)
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
*/
private $id;
@dadangnh I also tried this just a few days ago and for me it worked. Did you also add an import statement for the generator class?
use Ramsey\Uuid\Doctrine\UuidGenerator;
@dadangnh I also tried this just a few days ago and for me it worked. Did you also add an import statement for the generator class?
use Ramsey\Uuid\Doctrine\UuidGenerator;
aah this one solve the problem.. I only import the Ramsey\Uuid\UuidInterface but forgot the UuidGenerator..
Thank you, it's worked now