Skip to content
Discussion options

You must be logged in to vote

Hi! I'd write a class that stores information in memory, and then would send the data at the end of the request.

In Laravel, you can execute code at the end of an HTTP request using a middleware and the terminate method. Create a middleware using the following Artisan command:

php artisan make:middleware TerminateMiddleware

This will generate a new middleware class named TerminateMiddleware in the app/Http/Middleware directory. Open the file and modify it:

<?php

namespace App\Http\Middleware;

use Closure;

class TerminateMiddleware
{
    public function handle($request, Closure $next)
    {
        return $next($request);
    }

    public function terminate($request, $response)
    {
 …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@esimonetti
Comment options

Answer selected by esimonetti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants