gpt4 book ai didi

php - Doctrine AnnotationRegistry registerLoader 替换

转载 作者:行者123 更新时间:2023-12-05 04:03:56 25 4
gpt4 key购买 nike

要设置基于 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)

因此我不明白应该使用什么。

谢谢你的建议

最佳答案

AnnotationRegistry 已弃用,并将在 doctrine/annotations 2.0 中删除,但目前仍然需要它。

如果您已经设置了自动加载器,他们建议的简单解决方法是通过传入 'class_exists' 来设置 AnnotationRegistry,这是一个 php callable简单检查类是否存在并返回 true/false 的函数。

AnnotationRegistry::registerLoader('class_exists');

关于php - Doctrine AnnotationRegistry registerLoader 替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53068341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com