代码之家  ›  专栏  ›  技术社区  ›  Jakob Abfalter

条令注释注册登记册装载机更换

  •  1
  • Jakob Abfalter  · 技术社区  · 7 年前

    要设置基于symphoy注释的路由,我有这一行

    AnnotationRegistry::registerLoader([$loader, 'loadClass']);
    

    它工作正常,但已被弃用:

     * @return void
     *
     * @throws \InvalidArgumentException
     *
     * @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0
     *             autoloading should be deferred to the globally registered autoloader by then. For now,
     *             use @example AnnotationRegistry::registerLoader('class_exists')
     */
    public static function registerLoader(callable $callable)
    

    从那以后,我不知道该用什么来代替。

    谢谢你的建议

    1 回复  |  直到 7 年前
        1
  •  0
  •   Kerry Randolph    7 年前

    从评论中 here ,我认为annotationregistry已被弃用,但目前它仍然是必需的。

    如果您已经设置了自动加载程序,那么他们建议的简单解决方法是通过传入'class exists'来设置annotationregistry,这是 php callable 函数,该函数只检查类是否存在并返回true/false。

    AnnotationRegistry::registerLoader('class_exists');