Skip to content

Instantly share code, notes, and snippets.

@DougSisk
Created December 23, 2025 17:34
Show Gist options
  • Select an option

  • Save DougSisk/fcaca4cd9dd18a01026ff66375b59347 to your computer and use it in GitHub Desktop.

Select an option

Save DougSisk/fcaca4cd9dd18a01026ff66375b59347 to your computer and use it in GitHub Desktop.
Laravel Higher Memory Limit middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class HigherMemoryLimit
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next, int $limit = 1024): Response
{
ini_set('memory_limit', $limit.'M');
return $next($request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment