oozman's avatar

How can I use or enable Application events (App::before, App::after, etc.) in Lumen?

I'm trying to log some info about my application. And I'm thinking Application events are the better way to inject them.

How can I enable or use them in my Lumen project? or Are they not available at all?

App::before(function($request)
{
    //
});

App::after(function($request, $response)
{
    //
});

Thank you for the light shed.

0 likes
2 replies
thomaskim's avatar
Level 41

@oozman They are available, but you would need to register a middleware.

The lumen docs do a good job of covering middleware: http://lumen.laravel.com/docs/middleware

There is a section called "Before / After Middleware" that you would want to look at. There is also a section called "Registering Middleware" that tells you how to register it.

If you're confused about any of it, just let us know.

Please or to participate in this conversation.