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?
Not sure it will help or still need help, but try this
@ORM\CustomIdGenerator(class="\MyBundle\MyCustomGenerator")
ie add starting slash to class definition
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With