-
Notifications
You must be signed in to change notification settings - Fork 4
Middleware
やかみそら edited this page Aug 15, 2017
·
1 revision
Middleware provide a convenient mechanism for filtering something with your application.
You can create a middleware class under your app folder, such as app/middlewares/BeforeController.php
.
namespace app\middlewares;
use Kotori\Http\Request;
use Kotori\Http\Response;
class BeforeController
{
public function handle(Request $request, Response $response)
{
// do something
}
}
Then Kotori.php will execute the handle
function before controller class is initialized.
Don't forget to configure in the config array.
$config['middleware'] = [
'before_controller' => [
'\\app\\middlewares\\BeforeController',
],
];
Available hook names:
name |
---|
before_app |
after_app |
before_route |
after_route |
before_controller |
after_controller |
before_action |
after_action |