blackscorp / lazy-before-after-service-provider
A service Provider for Silex to call before/after methods automatically
v1.2.5
2015-05-15 21:09 UTC
Requires
- silex/silex: ~1.0
This package is auto-updated.
Last update: 2025-02-17 06:41:17 UTC
README
A service Provider for Silex to call before/after methods automatically.
#Usage
Your bootstrap may look like this
<?php $app = new Application(); $app->register(new ServiceControllerServiceProvider()); $app->register(new LazyBeforeAfterServiceProvider()); $app['controller'] = $app->share(function(){ return MyController(); }); $app->get('/','controller:indexAction');
Now you can just add methods like "before", "after","before{MethodName}" and "after{MethodName}" without to specify it in your Router.
This is the same like
$app->get('/','controller:indexAction') ->before(function(){ //some logic })->after(function(){ //some logic });
But with the ability to do your checks in a "Base" Controller and extend from it.
The Provider Call the methods in following Order:
- Before
- BeforeAction
- Action(Called by Silex)
- AfterAction
- After