Download the PHP package dizatech/burp without Composer
On this page you can find all versions of the php package dizatech/burp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dizatech/burp
More information about dizatech/burp
Files in dizatech/burp
Informations about the package burp
Burp
Simple php Router that can work with "URI", "QUERY STRING", or both.
It also has a simple Event Listener implementation (to fire or queue application events).
You can use Burp in your preferred framework (Including laravel), It does not pretend to be the only router, It just check your urls then fire or queue your events.
why
The idea is to have an "all in one" router,filter,event listener.
I'ts a way to build event-driven widgets and define a flexible "semantic" in application urls
Burp can power widgets that works driven by uri-segments,query-string or both, without the need to have a classic controller.
Installation
install via composer adding
if you're using laravel add the service provider in config/app.php:
'providers' => array(
...
'Zofe\Burp\BurpServiceProvider',
)
usage
Burp is similar to any other PHP router, but it can also behave as a filter.
There are two main differences you need to know:
-
a route rule can be strict or not strict (It means: "exact match", or "partial match" i.e. a non strict rule can match some uri-serment or some query-string parameter)
- rules are non-blocking, It means that a single http request can trigger more than one route
samples
Important:
- to define a "strict rule" you must use regex delimiters ^ and $
- to define a "parameter" you must parenthesis as in regex atom
bind controllers
you can bind a route to some class@method using 'uses' key:
usage - full example as front-controller
if you need burp in a "stand-alone" context, you need a front controller.
You can start from this .htaccess (most of application framework already have something like this)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
then you've to include burp, this is a way to have Burp as standalone router:
patterns
You can also declare and use pattern
Important: you must use parenthesis to define the atom/s
usage - in laravel
This snippet should give you the idea that you can use Burp to:
"define some behavior across laravel routes".
This url: /article/list?ord=-title
will fire "sort" event.
This url: /article/list/pg/2?ord=title
will fire "sort" and "page" events.
More, as you know laravel pagination work natively "only" with something like this:
/articles/list?page=1
, but in this sample for this controller It will work via segment:
/articles/list/pg/x
(without to create a custom pagination class).
Now you are also free to change your url-semantic in your router, for example switching from query-string to uri-segments or viceversa.
You can also move events and common behavior in a base controller and then extend this one