Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine orm:generate-proxies throwing "Can't instantiate custom generator"

Doctrine 2.5. When trying to generate proxies manually with

doctrine orm:generate-proxies

an exception is thrown:

[Doctrine\ORM\ORMException]
Can't instantiate custom generator : MyBundle\MyCustomGenerator

I have a custom generator defined which works correctly:

/**
 * @ORM\Column(type="string")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="CUSTOM")
 * @ORM\CustomIdGenerator(class="MyBundle\MyCustomGenerator")
 */
protected $id;

Also, instantiating the generator manually, like

$a = new MyBundle\MyCustomGenerator();

works. But for a reason the Doctrine Console throws the above exception.

I've tried to debug and check what's going on.
The exception is defined in completeIdGeneratorMapping of ClassMetadataFactory. I checked that $definition['class'] stores the name of my custom generator: MyBundle\MyCustomGenerator. But still, Doctrine can't find the class.
Thought I should add the definition to cli-config.php as explained in the doc, with use MyBundle or use MyBundle\MyCustomGenerator, but it did not work - still the same exception was thrown.

Any ideas how should I make the Doctrine Console aware of my custom ID generator?

like image 295
Taz Avatar asked Nov 10 '22 07:11

Taz


1 Answers

Not sure it will help or still need help, but try this

@ORM\CustomIdGenerator(class="\MyBundle\MyCustomGenerator")

ie add starting slash to class definition

like image 59
waney Avatar answered Dec 06 '22 08:12

waney