Doctrine annotation not existing

Six months ago, I set up a Zend Expressive project using Doctrine 2. I used the setup instructions found at https://www.jamestitcumb.com/posts/integrating-doctrine-expressive-easier — and all worked well. I later used the laminas migration tool on that Zend project and all seemed well.

More recently, I created an out of the box Mezzio sample project, used pretty much the same dependencies, copied the working entities into the new project, but get

‘[Semantical Error] The annotation “@Doctrine\ORM\Mapping\Entity” in class App\Entity\xxxx does not exist, or could not be auto-loaded’

I haven’t found any chat on StackExchange that seems to point to a solution that fits easily with my Lamnis project ----- is there some link that cleanly tells me how to deal with this issue? Is there some setup from the old zend expressive project I need to move to the new one?

Thanks

The same happened to me. The issue came down to doctrine-factories and PSR-11.

My tip for the day, without getting into details, take a look at -> https://github.com/Roave/psr-container-doctrine

Thanks for the quick reply.

So is the link a ‘hint’ of how to fix the issue by changing code, or a ‘hint’ to install psr-container-doctrine?

I see it requires PHP 7.3, (I’m at 7.2.24) but the update site is complaining about unsigned repositories which gives me pause:

Reading package lists… Done
W: GPG error: http://dl.google.com/linux/chrome/deb stable Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 78BD65473CB3BD13
E: The repository ‘http://dl.google.com/linux/chrome/deb stable Release’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.

So… did you change existing code, or fix the issue by installing psr-container-doctrine?

That error is completely unrelated to Composer; it looks like an error from apt-get, as it is referencing a debian repository.

Packages for PHP are installed using Composer. Can you verify that you were running composer update, composer install, or composer require?

Yes -
$ composer require roave/psr-container-doctrine

which then informed me that my version of PHP (7.2.24) was incompatible with the required version. That is when I used apt-get to update my PHP version to 7.3.

I hope that clears things up - regarding my process.

Okay - so you’ll need to sort what’s going on in your apt sources lists; it looks like you need to refresh the GPG key associated with the Chrome debian repositories so you can finish updating. If you need help with that, check Stack Overflow, as it’s outside the support we can offer here.

Once you’ve installed PHP 7.3, try running the composer require statement again.

If you still need a pre 7.3 version, use https://github.com/DASPRiD/container-interop-doctrine

Yes, thank you. I did upgrade to PHP 7.3, and installed the Roave package, but there was no change in the app behavior, as I still have problems with annotations not being auto-loaded. As far as I can tell, my code does pretty much everything as shown at that github site. That site includes a note under the example at https://github.com/Roave/psr-container-doctrine/blob/master/example/minimal-config.php that if using php, use the Annotation Driver and directs me to the full config — but the full config doesn’t have any obvious hints about using the Annotation Driver.
I’ve been tracing through the code, and I’ll post something once I get this figured out.

FIXED.

When I built this application, I based much of it on a zend-expressive example that included DoctrineORMModule and DoctrineModule. Including those packages with the out-of-the-box Laminas example was apparently a bad thing. All worked well once I removed them from my configuration (config.php) and cleaned up my composer.json…

   \Mezzio\Twig\ConfigProvider::class,
   \Mezzio\Router\FastRouteRouter\ConfigProvider::class,        
 //   \DoctrineORMModule\ConfigProvider::class,
 //   \DoctrineModule\ConfigProvider::class,

The code didn’t exactly give the intuitive error message I’d expect with such a foo-bar, but things are working now.

Once I started looking at the differences between in the vendor packages, things became apparent pretty quickly.

Thanks for your help!