thephpleague / glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.
http://glide.thephpleague.com
MIT License
2.55k stars 200 forks source link

0.3.6 to 1.2.2 League\Glide\Responses\LaravelResponseFactory Class does not exist on Laravel 5.1 #195

Closed commandantp closed 3 years ago

commandantp commented 7 years ago

Hi! I'm on Laravel 5.1 and Glide 0.3.6. Trying to upgrade to 1.2.2 I update composer with the new version and modified the code to get the following with the response. However I keep getting a League\Glide\Responses\LaravelResponseFactory Class does not exist.

Anything particular I'm missing? I've been reading the docs & issues but didn't find anything. Thanks!!

public function register()
    {
        //
        $this->app->singleton('League\Glide\Server', function ($app)
        {
             $filesystem = $app->make('Illuminate\Contracts\Filesystem\Filesystem');
            $factory = $app->make('\League\Glide\Responses\LaravelResponseFactory');
            return \League\Glide\ServerFactory::create([
                'response'              => $factory,
                'source'                => Storage::disk('s3')->getDriver(),
                'cache'                 => Storage::disk('local')->getDriver(),
                'source_path_prefix'    => 'uploads',
                'cache_path_prefix'     => 'uploads/images/.cache',
                'base_url'              => 'img',
                'useSecureURLs'         => false,
                ]);
        });
    }
Route::get('img/{path}', function (League\Glide\Server $server, Illuminate\Http\Request $request, $path)
{
    $server->getImageResponse($path, $request->all());
},['as' => 'img_thumbs'])->where('path', '.*');
daniel-keller commented 7 years ago

I have a similar setup with Laravel 5.2 and it seems to work. I'm relying on local storage instead of S3. Are you including the "league/glide-laravel" package in composer?

use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
...
public function register()
    {
        $this->app->singleton('League\Glide\Server', function($app) {
            $filesystem = new Filesystem(new Local(public_path()));
            $factory = $app->make('League\Glide\Responses\LaravelResponseFactory');

            return ServerFactory::create([
                'response' => $factory,
                'source' => $filesystem,
                'cache' => $filesystem,
                'cache_path_prefix' => '.cache',
                'base_url' => '/img/'
            ]);
        });
    }