N
N
nepster-web2017-02-14 21:03:18
Laravel
nepster-web, 2017-02-14 21:03:18

How to catch Response object before response in laravel 5?

There is a task to globally control what will be returned by the application (laravel5/lumen).
Using the controller as an example, it could be something like this:

echo '...';
return '...';
return view();
return response('...');
...

It is necessary to put something like this in some global x-place:
if (!$response instedOf Response) {
...
}

To be able to return only one Response object (a custom wrapper over a boxed one).
Previously, laravel had global events that you could subscribe to, but I did not find anything similar for version 5.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor, 2017-02-14
@nepster-web

https://laravel.com/docs/5.4/middleware
Before & After Middleware Section

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question