laravel-doctrine / extensions

Extensions integration for Doctrine2 and Laravel
http://laraveldoctrine.org/
MIT License
47 stars 24 forks source link

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

Open kunxin-chor opened 6 years ago

kunxin-chor commented 6 years ago

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
garret-gunter commented 6 years ago

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;
oleksandr-shubin commented 6 years ago

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 commented 6 years ago

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.