extensions
extensions copied to clipboard
Unable to load extension annonation using Laravel 5.5, Laravel-Doctrine 1.4.2
Hi I am trying to use the Timestamp extension, however when I attempt update the schema I get the following:
[Semantical Error] The annotation "@Gedmo\Mapping\Annotation\Timestampable" in property
App\Contacts\Domain\Contact\Contact::$created_at does not exist, or could not be auto-
loaded.
Here's the property in question:
/**
* @Gedmo\Timestampable(on="create")
* @ORM\Column(type="datetime", nullable=true)
*/
protected $created_at;
I have tried:
- Including the GedmoExtensionServiceProvider
- Including the DoctrineServiceProvider after the former (and the other way round)
- Flushing my config cache
Do you have the extension enabled in config/doctrine.php
?
And when you say flushing config cache, have you flushed the metadata cache for doctrine? If you are using the file cache driver for laravel, doctrine will save the metadata cache with strict permissions. Meaning you have to be the owner or admin to delete them. The issue is that artisan doesn't tell you if it couldn't delete them. It's a problem with laravel's cache file driver. My advice is to use array driver for metadata while making new entities.
Another thing, are you import the gedmo annotations to the class?
use Gedmo\Mapping\Annotation as Gedmo;
I've got same problem, using trait "Timestamps".
It already has
use Gedmo\Mapping\Annotation as Gedmo;
I tried:
-
doctrine:clear:metadata:cache
- This solution. To move service provider above - however since Laravel 5.5 I shouldn't register it manually, anyway it didn't help
Adding
LaravelDoctrine\Extensions\GedmoExtensionsServiceProvider::class,
to config/app.php solved the issue. I understand that this is described in official documentation
https://www.laraveldoctrine.org/docs/1.3/extensions/installation
However the latest one is for 1.3, moreover for the reason described in above comment, I assumed that GedmoExtensionsServiceProvider::class
should be auto-discovered.