Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2016-04-13 (6 months ago) | | Not yet rated by the users | | Total: 146 This week: 1 | | All time: 8,195 This week: 1,047 |
|
Description | | Author |
This package can run queued processes using the middleware pattern.
A queue class can add middleware objects or closure functions to a queue to be executed on the first in, first out basis.
The queue class can take the middleware objects from the queue, call them and return the responses.
The middleware objects can execute the next object in the queue. Innovation Award
February 2016
Number 3
Prize: One ebook of choice by Packt |
Middleware is a piece of software that connects different pieces of software to perform a certain action.
This package implements generic middle functionality for the process of queuing and processing a certain task using middleware objects and returning the results to the calling code.
Manuel Lemos |
| |
|
|
Innovation award
Nominee: 2x |
|
Details
Class Application {
function __construct(){
$this->request = [];
$this->response = [];
// or
$this->request = new \stdClass;
$this->response = new \stdClass;
}
}
$application = new Application;
or
$application = new \stdClass()
$application->request = new \stdClass()
$application->response = new \stdClass()
$MiddlewareQueue = new MiddlewareQueue($application);
$MiddlewareQueue->add(function($req, $res, $next){
echo 'A ';
$next();
echo 'A_2 ';
});
Class OneMiddleware extends Middleware {
public function call(){
echo 'B ';
$this->next->call();
echo 'B_2 ';
}
}
$MiddlewareQueue->add(new OneMiddleware);
Class Two {
public function call(){
echo 'C ';
$this->next->call();
echo 'C_2 ';
}
}
$MiddlewareQueue->add(new Two);
$MiddlewareQueue->add(function($req, $res, $next){
echo 'D ->';
$next();
echo 'D_2 ';
});
$MiddlewareQueue->run();
RESULT:
A B C D -> D_2 C_2 B_2 A_2
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.