DonSchoeman's avatar

Now that Laravel 5.4 no longer support 'kernel.handled' events, what do we do in Lumen?

Some popular libraries such as barryvdh/laravel-cors requires HTTP headers being added after a request have been handled. It does it in the following way so it works both in Laravel and Lumen:

if (class_exists(RequestHandled::class)) {
    $this->events->listen(RequestHandled::class, function(RequestHandled $event) use ($cors) {
        $cors->addActualRequestHeaders($event->response, $event->request);
    });
} else {
    $this->events->listen('kernel.handled', function($request, $response) use ($cors) {
        $cors->addActualRequestHeaders($response, $request);
    });
}

The problem is that Laravel no longer seems to supports the listen('kernel.handled'... way of listening to events. What are Lumen developers suppose to do as the RequestHandled class form part of the Foundation classes in Laravel and is not available in Lumen, so now there doesn't seem to be a way to add this type of event listener any more, or am I missing something?

0 likes
0 replies

Please or to participate in this conversation.