Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Laravel / Lumen json options for response using middleware. Used for returning unescaped utf-8 unicode response.
<?php
namespace App\Http\Middleware;
use Closure;
class UnescapedJsonMiddleware
{
public function handle($request, Closure $next)
{
$data = $next($request);
$data->setEncodingOptions(JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
return $data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.