Пример #1
0
> **Note:-**
>
>  1. Using session variables as DB and Cache is useless for real life and wrong. We are using it
>     Only for demo purpose. Since API Explorer is browser based it works well with that.
>
>  2. We are using Author.php to document return type of `GET authors/{id}` using `@return` comment

If you have hit the API Rate Limit or screwed up the Authors DB, you can easily reset by deleting
PHP_SESSION cookie using the Developer Tools in your browser.

Helpers: Author

Footer:
*[Author.php]: _009_rate_limiting/Author.php
*/
use Luracast\Restler\Defaults;
use Luracast\Restler\Filter\RateLimit;
use Luracast\Restler\Restler;
require_once '../../../vendor/restler.php';
//reuse the SessionDB from CRUD Example
require_once '../_007_crud/DB/Session.php';
//used only for demo, comment the following line
Defaults::$cacheClass = 'SessionCache';
//set extreme value for quick testing
RateLimit::setLimit('hour', 10);
$r = new Restler();
$r->addAPIClass('ratelimited\\Authors');
$r->addAPIClass('Resources');
$r->addFilterClass('RateLimit');
$r->addAuthenticationClass('KeyAuth');
$r->handle();