PHP code example of melonsmasher / laravel-glide

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

    

melonsmasher / laravel-glide example snippets


// config/app.php

'provider' => [
    //...
    Axn\LaravelGlide\ServiceProvider::class,
    //...
];

// config/app.php

'aliases' => [
    //...
    'Glide' => Axn\LaravelGlide\Facade::class,
    //...
];

// App/Http/routes.php

Route::get(config('glide.servers.images.base_url').'/{path}', [
    'uses' => 'GlideController@images'
])->where('path', '(.*)');

Route::get(config('glide.servers.avatars.base_url').'/{path}', [
    'uses' => 'GlideController@avatars'
])->where('path', '(.*)');



namespace App\Http\Controllers;

use Glide;
use Illuminate\Http\Request;

class GlideController extends Controller
{
    public function images($path, Request $request)
    {
        return Glide::server('images')->imageResponse($path, $request->all());
    }

    public function avatars($path, Request $request)
    {
        return Glide::server('avatars')->imageResponse($path, $request->all());
    }
}
sh
php artisan vendor:publish --provider="Axn\LaravelGlide\ServiceProvider"
sh
php artisan glide:key-generate
blade
<!-- From default server -->
<img src="{{ Glide::url('example1.jpg', ['w' => 500, 'h' => 300, 'fit' => 'crop']) }}">

<!-- From "avatars" server -->
<img src="{{ Glide::server('avatars')->url('example2.jpg', ['w' => 250, 'fit' => 'fill']) }}">