php loep/oauth2服务器致命错误


php-loep / oauth2-server Fatal error

有人能在这里给我指明正确的方向吗?我一直在得到错误:致命错误:在第4行的F:''Work''examplep''htdocs''oauth''test.php中找不到类"src''League ''OAuth2''Server''Util''Request"

在php loep/oauth2服务器的test.php中执行下面的测试代码之后。全班同学就在那儿。请告诉我如何实现这个oauth2服务器。

<?php
// Initiate the Request handler
$request = new src'League'OAuth2'Server'Util'Request();
// Initiate a new database connection
$db = new src'League'OAuth2'Server'Storage'PDO'Db('mysql://user:pass@localhost/oauth');
// Initiate the auth server with the models
$server = new src'League'OAuth2'Server'Resource(new League'OAuth2'Server'Storage'PDO'Session($db));
?>

我认为您混淆了名称空间和路径声明。顺便说一下,Request的命名空间是League'OAuth2'Server'Util,所以调用必须是:

$request = new League'OAuth2'Server'Util'Request();

但在使用它之前,您需要一个自动加载器,或者必须包含该类。

include __DIR__."/src/League/OAuth2/Server/Util/Request.php";

如果您需要自动加载器,您可以使用PSR-0自动加载器:

SplClassLoader.php

其他阅读关于PHP命名空间:命名空间

相关文章: