middleware
is an abstract class that all middleware
objects you write, should inherit from. All middleware
should be in a file located in the paths.middleware
configuration settings folder and should be named in the format of file.middleware.php. The classes should all be named in the format of fileMiddleware
and must extend the \iPinga\middleware
class.
You can tell iPinga
to call a list of middleware
by providing a pipe separated string of middleware
names as the fourth paramter to ipinga->addRoute()
Parent Class
None
Public Methods
middleware
should return true if it is okay to continue past this check. All middleware
must have a call()
method.Parameters:
none
Returns:
True if this middleware saw now reason why the program should not continue loading the route (after processing additional middleware if there is any).
Example:
1 2 3 4 5 6 7 8 9 10 11 |
require_once __DIR__ . '/vendor/autoload.php'; // Autoload files using Composer autoload $iPinga = new \ipinga\ipinga(); // Tell iPinga how to handle various requests $iPinga->addRoute('user/list','user','showList'); $iPinga->addRoute('user/add','user','add'); $iPinga->addRoute('user/get/$1','user','details','mustBeLoggedIn'); // Calls the mustBeLoggedInMiddleware->call() method $iPinga->defaultRoute('user','index'); $iPinga->run(); |