Skip to content

Commit 9750477

Browse files
authored
Merge pull request #23 from crowdsecurity/new-lib-features
update docs
2 parents 81a4284 + 6a57309 commit 9750477

File tree

3 files changed

+12
-33
lines changed

3 files changed

+12
-33
lines changed

README.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,21 @@ In your PHP project, just add these lines to verify an IP:
4343

4444
```php
4545

46-
/* To get a bouncer api key: "cscli bouncers add <name-of-your-php-bouncer> */
47-
$bouncerApiKey = 'YOUR_BOUNCER_API_KEY';
46+
<?php
47+
use CrowdSecBouncer\Bouncer;
4848

49-
/* Select the best cache adapter for your needs (Memcached, Redis, PhpFiles, ...) */
50-
$cacheAdapter = new Symfony\Component\Cache\Adapter\PhpFilesAdapter();
49+
// Init bouncer
50+
$bouncer = new Bouncer();
51+
$bouncer->configure(['api_key' => 'YOUR_BOUNCER_API_KEY', 'api_url' => 'http://127.0.0.1:8080']);
5152

52-
$bouncer = new CrowdSecBouncer\Bouncer($cacheAdapter);
53-
$bouncer->configure(['api_key'=> $bouncerApiKey]);
54-
55-
$remediation = $bouncer->getRemediationForIp($blockedIp);// Return "ban", "captcha" or "bypass"
53+
// Ask remediation to API
54+
$remediation = $bouncer->getRemediationForIp($requestedIp);
55+
echo "\nResult: $remediation\n\n"; // "ban", "captcha" or "bypass"
5656
```
5757

58-
View [`docs/complete-guide.md`](https://github.com/crowdsecurity/php-cs-bouncer/blob/main/docs/complete-guide.md) to learn how to include this library in your project in minutes.
58+
View [`examples/live-mode/full-example-live-mode.php`](examples/live-mode/full-example-live-mode.php).
59+
60+
> You can also follow the [`docs/complete-guide.md`](docs/complete-guide.md) to learn how to include this library in your project in minutes.
5961
6062
## Future
6163
- Retrieve decisions stored in cache using pagination

docs/contribute.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ After the merge, don't forget to delete to branch.
7575
```bash
7676
git describe --tags # to verify what is the current tag
7777
gh release create --draft vx.x.x --title vx.x.x
78-
```
78+
```

examples/live-mode/simple-example-live-mode.php

-23
This file was deleted.

0 commit comments

Comments
 (0)