PHP code example of flobbos / laravel-image-cache

1. Go to this page and download the library: Download flobbos/laravel-image-cache 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/ */

    

flobbos / laravel-image-cache example snippets


use Flobbos\LaravelImageCache\Facades\ImageCache;

// Apply the "small" template to an image
$cachedImage = ImageCache::template('path/to/image.jpg', 'small');

namespace App\ImageTemplates;

use Flobbos\LaravelImageCache\Contracts\TemplateInterface;
use Intervention\Image\Interfaces\ImageInterface;

class CustomTemplate implements TemplateInterface
{
    public function build(ImageInterface $image): void
    {
        $image->resize(800, 600);
    }
}

'templates' => [
    'custom' => \App\ImageTemplates\CustomTemplate::class,
],

'paths' => [
    public_path('images'),
    storage_path('app/public/images'),
],

'dynamic_route' => 'imgcache',

route('imagecache.serve', ['template' => 'small', 'path' => 'example.jpg']);
bash
    php artisan vendor:publish --tag=config --provider="Flobbos\LaravelImageCache\ImageCacheServiceProvider"