简体   繁体   English

教义注释失败

[英]Doctrine Annotation failing

Currently I'm trying to implement the Doctrine CouchDB Bundle in a Silex Application. 目前,我正在尝试在Silex应用程序中实现Doctrine CouchDB捆绑软件。 At one point the complete site ends in a 500/internal server error in my local dev stack. 有一点整个站点以我本地开发堆栈中的500/internal server error结束。 Setting breakpoints and debugging them with XDebug and PHPStorm hasn't brought me to any result so far. 到目前为止,设置断点并使用XDebug和PHPStorm调试它们并没有带来任何结果。 Apache Error logs are empty, PHP error logs as well and error_reporting(-1); Apache错误日志为空,PHP错误日志也为空, 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 一切工作正常, 直到我尝试使用CouchDB Annotations

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. 如果删除上面的CouchDB\\ ,一切正常。 But if I remove it, and use @Id(strategy="ASSIGNED") , I run into the exact same problem. 但是,如果我删除它,并使用@Id(strategy="ASSIGNED") ,则会遇到完全相同的问题。

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). @Ocramius在聊天中建议我应该简单地重写Autoloader,这样可以很好地解决其他问题,但不适用于这种情况(如果有人需要,可以在此处添加它)。

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');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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