1

我正在运行以下 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{  }
4

3 回答 3

0

您是否正确定义了命名空间是 iAuthenticate 是否有效且已定义

您是否正在自动加载命名空间 Luracast\Restler\iAuthenticate ?

于 2013-02-09T11:42:57.203 回答
0

在我的测试中它工作得很好

看这个

命名空间 Luracast\Restler;

接口 iAuthenticate {

}

使用 Luracast\Restler\iAuthenticate as ia;

类 SimpleAuth 实现 ia {

    常量键 = 'rEsTlEr2';

    函数 __isAllowed() {
        返回 isset($_GET['key']) && $_GET['key'] == SimpleAuth::KEY ? 真假;
    }

    功能键(){
        返回 SimpleAuth::KEY;
    }

}

于 2013-02-09T12:05:41.327 回答
0

看起来你直接调用了你不应该做的`C:\wamp\www\Restler\public\examples\nof\SimpleAuth.php',除非你包含restler.php,否则它不会工作

确保您的 index.php 正确包含 restler.php,一旦这样做,我们的自动加载器应该能够加载 'Luracast\Restler\iAuthenticate' 就好了。

您不应该尝试自己创建restler api 类。

于 2013-02-09T13:26:35.090 回答