PHP Classes


Recommend this page to a friend!
  Classes of Vitalij Mik   Lazy Before After Service Provider   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Lazy Before After Service Provider
Call functions before or after a controller action
Author: By
Last change:
Date: 6 years ago
Size: 1,098 bytes


Class file image Download


Build Status

A service Provider for Silex to call before/after methods automatically.


Your bootstrap may look like this

$app = new Application();
$app->register(new ServiceControllerServiceProvider());
$app->register(new LazyBeforeAfterServiceProvider());
$app['controller'] = $app->share(function(){
return MyController();

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

//some logic
//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:

  1. Before
  2. BeforeAction
  3. Action(Called by Silex)
  4. AfterAction
  5. After