简体   繁体   中英

Doctrine Annotation failing

Currently I'm trying to implement the Doctrine CouchDB Bundle in a Silex Application. At one point the complete site ends in a 500/internal server error in my local dev stack. Setting breakpoints and debugging them with XDebug and PHPStorm hasn't brought me to any result so far. Apache Error logs are empty, PHP error logs as well and error_reporting(-1); still doesn't give any output. Probably the problem is the reflection class usage in there.

Everything works well, until I try to use CouchDB Annotations from

use Doctrine\ODM\CouchDB\Mapping\Annotations as CouchDB;

and use them in my Document

/** @CouchDB\Document */
class Station
{
    /**
     * @Index
     * @Id
     */
    private $id;

If I remove the CouchDB\\ above, everything works. But if I remove it, and use @Id(strategy="ASSIGNED") , I run into the exact same problem.

I tried to register the Annotations in several ways without luck. @Ocramius suggested in chat that I should simply override the Autoloader, which worked well with getting beyond some other problems, but not for that case (just adding it here in case someone else needs it).

AnnotationRegistry::registerLoader( function( $className ) {
    return class_exists( $className );
} );

Try to use

/**
* @CouchDB\Index
* @CouchDB\Id
*/

instead of

/**
* @Index
* @Id
*/

您还可以通过在运行Silex应用程序之前添加此行来解决此问题(可能在index.php中)。

AnnotationRegistry::registerLoader('class_exists');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM