0

我正在使用slim4。为了验证用户令牌,添加到 ResourceServer 类到容器(依赖注入)如下

use Psr\Container\ContainerInterface;
use DI\ContainerBuilder;
use Slim\Views\Twig;

$containerBuilder = new ContainerBuilder();

$container = $containerBuilder->build();

$container->set(
    ResourceServer::class,
    function ( ContainerInterface $container )
    {
        $server = new ResourceServer(
            new AccessTokenRepository(),
            'file://' . __DIR__ . '/../src/configs/private.key'
        );

        return $server;
    }
);

.........................然后将以下内容添加到路线中

$app->get('/user', UserController::class . ':getuserinfo')->add(new ResourceServerMiddleware($app->getContainer()->get(ResourceServer::class)));

这是抛出错误“找不到'ResourceServer'的条目或类”

任何帮助表示赞赏

4

0 回答 0