Permalink
Browse files

Add README and branch-alias

  • Loading branch information...
1 parent 2a0a153 commit 7f6bef699a6014994c034804755aa2678a73e552 @dongilbert dongilbert committed Nov 1, 2013
Showing with 49 additions and 0 deletions.
  1. +44 −0 README.md
  2. +5 −0 composer.json
View
@@ -0,0 +1,44 @@
+# League\StackAttack
+
+StackAttack is a blocking & throttling middleware for StackPHP, based heavily off of [Rack::Attack](https://github.com/kickstarter/rack-attack) for Ruby.
+It currently allows _whitelisting_ and _blacklisting_.
+
+## Install Via Composer
+
+ {
+ "require": {
+ "league/stack-attack": "~1.0"
+ }
+ }
+
+## Example
+
+ <?php
+
+ include_once '../vendor/autoload.php';
+
+ use Symfony\Component\HttpFoundation\Request;
+ use Symfony\Component\HttpFoundation\Response;
+ use League\StackAttack\FilterCollection;
+
+ $app = new Stack\CallableHttpKernel(function (Request $request) {
+ return new Response('Hello World!');
+ });
+
+ $filters = (new FilterCollection)
+ ->blacklist('Block dev requests.', function (Request $request) {
+ return strpos($request->getPathInfo(), '/dev') === 0;
+ });
+
+ $options = array(
+ 'blacklistedResponse' => function (Request $request) {
+ // A 503 response makes some bots think they had a successful DDOS
+ return new Response('Service Unavailable', 503);
+ }
+ );
+
+ $app = (new Stack\Builder)
+ ->push('League\\StackAttack\\Attack', $filters, $options)
+ ->resolve($app);
+
+ Stack\run($app);
View
@@ -16,5 +16,10 @@
"psr-0": {
"League\\StackAttack\\": "src/"
}
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
}
}

0 comments on commit 7f6bef6

Please sign in to comment.