PHP code example of avtonom / limit-number-calls-bundle
1. Go to this page and download the library: Download avtonom/limit-number-calls-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
avtonom / limit-number-calls-bundle example snippets
$bundles(
...
new Snc\RedisBundle\SncRedisBundle(),
new Avtonom\LimitNumberCallsBundle\AvtonomLimitNumberCallsBundle(),
...
);
php
# for Symfony > 3.0
if (!$this->get('security.authorization_checker')->isGranted('sms_group', $Object)) {
throw new \Exception('Too Many Requests', 429);
}
# for Symfony < 3.0
if (!$this->get('security.context')->isGranted('sms_1m_rule', $Object)) {
throw new \Exception('Too Many Requests', 429);
}