When i try to generate entities or update the schema;
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@index" in class Gedmo\Translatable\Entity\Translation was never imported. Did you maybe forget to add a "use" statement for this annotation?
What is the problem?
I have tried;
More information:
I'm not using gedmo translations now. It's installed but not used!
I don't have any use of translation annotations.
This happened after updating symfony2.4 to 2.6.
Unfortunately the class doc-block of Gedmo\Translatable\Entity\Translation
contains the annotation @index
(in stead of @Index
, with a capital "I"). This can cause issues on case-sensitive filesystems.
This has been fixed in commit 1926773: Removed unused use statements and added a missing one, but that hasn't been tagged/released yet.
Because you upgraded Symfony, you probably also upgraded Doctrine. I'm not sure in which version of Doctrine this happened, but in the past missing annotations were simply ignored. Nowadays an exception is thrown. This is probably why you're having this issue after an upgrade.
One solution is to ignore the @index
(lowercase "i") annotations:
AnnotationReader::addGlobalIgnoredName('index');
Documentation: 2.2.3. Ignoring missing exceptions
Or completely disable the import validation mechanism:
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$reader->setEnabledPhpImports(false);
Documentation: 2.2.4. PHP Imports
Note that this last feature will be removed in future versions of Doctrine.
Even though you're not using the Translatable extension, you probably have its mappings enabled. Otherwise the class wouldn't be loaded and the error wouldn't occur.
Search for something like this in your app/config/config.yml
:
doctrine:
orm:
entity_managers:
default:
mappings:
gedmo_translatable:
type: annotation
prefix: Gedmo\Translatable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
alias: GedmoTranslatable
is_bundle: false
gedmo_translator:
type: annotation
prefix: Gedmo\Translator\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
alias: GedmoTranslator
is_bundle: false
You should only include the mappings of the extensions you're actually using.
Change the requirement of gedmo/doctrine-extensions
in your composer.json
to at least 1926773. You could also ask the maintainer to release a new version that includes the bug-fix.
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