league/glide
Glide is an on-demand PHP image manipulation library with an HTTP API. Resize, crop, and apply effects, then cache results with far-future headers. Works with GD, Imagick, or libvips, integrates with Flysystem, and can sign URLs for security.
Illuminate\Http\Request)./images/*) and delegate processing to Glide.Storage facade) for S3, local filesystems, or cloud storage, reducing boilerplate./images/{filename}.jpg?w=500 to Glide’s endpoint (e.g., via Laravel routes or a reverse proxy like Nginx).blur=50) may strain servers using GD. Imagick/libvips recommended for production.memory_limit (configurable via Server).Storage events or a cron job to clear cache.source paths could expose files outside the intended directory (validate paths rigorously).intervention/image). Use resolver in composer.json if needed.HandleGlideRequests middleware)./images/*) to Glide.Storage facade to configure Flysystem adapters for source/cache./images/avatar.jpg?w=200)./images/* to Glide.<img src="{{ glide_url($image, ['w' => 300]) }}">).php-imagick extension.php-vips (Linux-only).$server = League\Glide\ServerFactory::create([
'source' => storage_path('app/public/images/source'),
'cache' => storage_path('app/public/images/cache'),
'base_url' => '/images',
]);
// app/Http/Middleware/GlideMiddleware.php
public function handle($request, Closure $next) {
if ($request->is('images/*')) {
$server->outputImage($request);
return response()->noContent();
}
return $next($request);
}
// routes/web.php
Route::get('/images/{path}', function ($path) {
$server->outputImage($path, request()->query());
});
// Helper function to generate Glide URLs
function glide_url($path, array $params = []) {
$query = http_build_query($params);
return route('glide.images', $path) . '?' . $query;
}
<img src="{{ glide_url('avatars/user123.jpg', ['w' => 100, 'h' => 100, 'fit' => 'crop']) }}">
Server config)..env for paths (e.g., GLIDE_SOURCE=s3://bucket/images).error_log for debuggingHow can I help you explore Laravel packages today?