extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Unable to load extension annonation using Laravel 5.5, Laravel-Doctrine 1.4.2

Open kunxin-chor opened this issue 7 years ago • 3 comments

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:

  1. Including the GedmoExtensionServiceProvider
  2. Including the DoctrineServiceProvider after the former (and the other way round)
  3. Flushing my config cache

kunxin-chor avatar Jan 08 '18 03:01 kunxin-chor

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;

garret-gunter avatar Jan 12 '18 01:01 garret-gunter

I've got same problem, using trait "Timestamps". It already has use Gedmo\Mapping\Annotation as Gedmo; I tried:

  1. doctrine:clear:metadata:cache
  2. This solution. To move service provider above - however since Laravel 5.5 I shouldn't register it manually, anyway it didn't help

oleksandr-shubin avatar Jun 14 '18 16:06 oleksandr-shubin

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.

oleksandr-shubin avatar Jun 14 '18 17:06 oleksandr-shubin