要设置基于 Symphoy 注释的路由,我有这条线
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
Run Code Online (Sandbox Code Playgroud)
它工作正常,但已被弃用:
* @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)
Run Code Online (Sandbox Code Playgroud)
从那以后我不明白我应该用什么来代替。
感谢您的任何建议
AnnotationRegistry 已被弃用,并将在doctrine/annotations 2.0 中删除,但目前仍然是必需的。
如果您已经设置了自动加载器,他们建议的简单解决方法是通过传入“class_exists”来设置 AnnotationRegistry,这是一个php 可调用函数,只需检查类是否存在并返回 true/false。
AnnotationRegistry::registerLoader('class_exists');
Run Code Online (Sandbox Code Playgroud)