Skip to content

Instantly share code, notes, and snippets.

@imanghafoori1
Last active February 22, 2018 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imanghafoori1/ec8f653ccbe4858c0a4343e7c522b032 to your computer and use it in GitHub Desktop.
Save imanghafoori1/ec8f653ccbe4858c0a4343e7c522b032 to your computer and use it in GitHub Desktop.
<?php
function sendAndExit($response)
{
$request = app('request');
// send the response to the users browser
app('router')->prepareResponse($request, $response)->send();
// dispatches an event
app('events')->dispatch(new \Illuminate\Foundation\Http\Events\RequestHandled($request, $response));
// this is just needed when we have terminable middlewares in our app.
app(\Illuminate\Contracts\Http\Kernel::class)->terminate($request, $response);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment