1. Go to this page and download the library: Download jcfrane/laravel-lens library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
'lock' => [
'enabled' => env('LENS_LOCK_ENABLED', false),
'store' => null, // Laravel cache store for the atomic lock (null = default)
'timeout' => 30, // seconds the generating request may hold the lock
'wait' => 15, // seconds concurrent requests wait for the lock
],
use JCFrane\LaravelLens\Facades\Lens;
// Get the URL for a filtered image
$url = Lens::url('photos/landscape.jpg', 'thumbnail_small');
// Process and cache an image immediately
$binary = Lens::resolve('photos/landscape.jpg', 'thumbnail_small');
// Check if a filtered image is cached
$cached = Lens::isCached('photos/landscape.jpg', 'thumbnail_small');
// Where the cached variant lives on the cache disk (null for no_cache)
$path = Lens::cachedPath('photos/landscape.jpg', 'thumbnail_small');
// => 'lens-cache/thumbnail_small/photos/landscape.jpg'
// Stream the cached variant as an HTTP response without loading it into
// memory (null when not cached — generate or fall back yourself)
$response = Lens::cachedResponse('photos/landscape.jpg', 'thumbnail_small', headers: [
'Cache-Control' => 'public, max-age=31536000, immutable',
]);
// Invalidate cached images
Lens::invalidate('photos/landscape.jpg');
Lens::invalidate('photos/landscape.jpg', ['thumbnail_small']);
use Intervention\Image\Interfaces\ImageInterface;
use JCFrane\LaravelLens\Contracts\FilterInterface;
class SepiaFilter implements FilterInterface
{
public function apply(ImageInterface $image, array $options = []): ImageInterface
{
return $image->greyscale()->brightness(-10)->contrast(10);
}
public function name(): string
{
return 'sepia';
}
}
use JCFrane\LaravelLens\Facades\Lens;
Lens::filterManager()->register('sepia', new SepiaFilter());