PHP Classes

Lazy Before After Service Provider: Call functions before or after a controller action

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 51 All time: 10,677 This week: 455Up
Version License PHP version Categories
lazybeforeafterservi 1.0Custom (specified...5PHP 5, Libraries, Design Patterns
Description 

Author

This package can call functions before or after a controller action.

It can register callback functions for an application controller that is assigned to handle application actions.

The callback functions can be called respectively before and after the specified controller action is called.

Picture of Vitalij Mik
  Performance   Level  
Name: Vitalij Mik <contact>
Classes: 7 packages by
Country: Germany Germany
Age: 37
All time rank: 3482194 in Germany Germany
Week rank: 170 Up11 in Germany Germany Up
Innovation award
Innovation award
Nominee: 5x

Documentation

LazyBeforeAfterServiceProvier

Build Status

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:

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

  Files folder image Files (18)  
File Role Description
Files folder imagesrc (2 files)
Files folder imagetest (1 directory)
Files folder imagetests (1 directory)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (18)  /  src  
File Role Description
  Plain text file LazyBeforeAfterEventSubscriber.php Class Class source
  Plain text file LazyBeforeAfterServiceProvider.php Class Class source

  Files folder image Files (18)  /  test  
File Role Description
Files folder imageSpy (9 files)

  Files folder image Files (18)  /  test  /  Spy  
File Role Description
  Plain text file BaseControllerSpy.php Class Class source
  Plain text file ControllerOnlyActionSpy.php Class Class source
  Plain text file ControllerWithAfterActionOnlySpy.php Class Class source
  Plain text file ControllerWithAfterOnlySpy.php Class Class source
  Plain text file ControllerWithAllSpy.php Class Class source
  Plain text file ControllerWithBeforeActionOnlySpy.php Class Class source
  Plain text file ControllerWithBeforeOnlySpy.php Class Class source
  Plain text file ControllerWithOrderSpy.php Class Class source
  Plain text file ControllerWithSymfonyResponseSpy.php Class Class source

  Files folder image Files (18)  /  tests  
File Role Description
Files folder imageintegration (1 file)

  Files folder image Files (18)  /  tests  /  integration  
File Role Description
  Plain text file LazyBeforeAfterServiceProviderTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:51
This week:0
All time:10,677
This week:455Up