Search code examples
phprestler

while running SimpleAuth.php it gives fatal error in restler


I am running this following url and trying to run SimpleAuth.php

http://localhost/restler/public/examples/nof/SimpleAuth.php and it gives

Fatal error: Interface 'Luracast\Restler\iAuthenticate' not found in C:\wamp\www\Restler\public\examples\nof\SimpleAuth.php on line 5

content of 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{  }

Solution

  • it looks like you are directly calling `C:\wamp\www\Restler\public\examples\nof\SimpleAuth.php' which you should not be doing, and it wont work unless you include restler.php

    make sure your index.php includes restler.php correctly, once it does so, our autoloader should be able to load the 'Luracast\Restler\iAuthenticate' just fine.

    You should not attempt creating restler api class yourself.