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.
Glide makes it possible to access images stored in a variety of file systems. It does this using the Flysystem file system abstraction library. For example, you may choose to store your source images on Amazon S3, but keep your rendered images (the cache) on the local disk.
To set your source and cache locations, simply pass an instance of League\Flysystem\Filesystem for each. See the Flysystem website for a complete list of available adapters.
<?php
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use League\Glide\ServerFactory;
// Setup Glide server
$server = ServerFactory::create([
'source' => new Filesystem(new Local('path/to/source/folder')),
'cache' => new Filesystem(new Local('path/to/cache/folder')),
]);
Alternatively, if you are only using the local disk, you can simply provide the paths as a string.
<?php
$server = League\Glide\ServerFactory::create([
'source' => 'path/to/source/folder',
'cache' => 'path/to/cache/folder',
]);
While it's normally possible to set the full source and cache path using Flysystem, there are situations where it may be desirable to set a default path prefix. For example, when only one instance of the Filesystem is available.
<?php
// Set using factory
$server = League\Glide\ServerFactory::create([
'source' => $filesystem,
'cache' => $filesystem,
'source_path_prefix' => 'source',
'cache_path_prefix' => 'cache',
]);
// Set using setter methods
$server->setSourcePathPrefix('source');
$server->setCachePathPrefix('cache');
How can I help you explore Laravel packages today?