我正在运行以下url并尝试运行SimpleAuth.php
http://localhost/restler/public/examples/nof/SimpleAuth.php
它给出了
Fatal error: Interface 'Luracast\Restler\iAuthenticate' not found in C:\wamp\www\Restler\public\examples\nof\SimpleAuth.php on line 5
SimpleAuth.php的内容
use Luracast\Restler\iAuthenticate;
class SimpleAuth implements iAuthenticate
{
const KEY = 'rEsTlEr2';
function __isAllowed()
{
return isset($_GET['key']) && $_GET['key'] == SimpleAuth::KEY ? TRUE : FALSE;
}
function key()
{
return SimpleAuth::KEY;
}
}
iAuthenticate.php
namespace Luracast\Restler;
interface iAuthenticate extends iFilter{ }
答案 0 :(得分:0)
您是否正确定义了命名空间 是iAuthenticate是有效和定义的
你是自动加载 命名空间Luracast \ Restler \ iAuthenticate与否?
答案 1 :(得分:0)
在我的测试中它的工作完美
看看这个
namespace Luracast\Restler; interface iAuthenticate { } use Luracast\Restler\iAuthenticate as ia; class SimpleAuth implements ia { const KEY = 'rEsTlEr2'; function __isAllowed() { return isset($_GET['key']) && $_GET['key'] == SimpleAuth::KEY ? TRUE : FALSE; } function key() { return SimpleAuth::KEY; } }
答案 2 :(得分:0)
看起来你直接调用`C:\ wamp \ www \ Restler \ public \ examples \ nof \ SimpleAuth.php'你不应该这样做,除非你包括restler.php否则它不会工作
确保你的index.php正确包含restler.php,一旦这样做,我们的自动加载器应该可以加载'Luracast \ Restler \ iAuthenticate'就好了。
您不应该自己尝试创建restler api类。