Closed denisgruba closed 7 years ago
@denisgruba: Follow the instructions in this video.
This instruction is only for glide 0.3.* So for example it doesn't work when in the routes we change : $server->outputImage($path, $_GET); to $server->outputImage($request);
This is how I managed to set ip up:
app/Providers/AppServiceProvider.php
<?php
namespace App\Providers;
use Storage;
use Illuminate\Support\ServiceProvider;
use League\Glide\ServerFactory;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('League\Glide\Server', function($app) {
$storageDriver = Storage::getDriver();
return ServerFactory::create([
'source' => $storageDriver,
'cache' => $storageDriver,
'cache_path_prefix' => '.cache',
'base_url' => '/img/'
]);
});
}
}
}
app/Http/routes.php
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('img/{path}', function($path, League\Glide\Server $server, Illuminate\Http\Request $request) {
$server->outputImage($path, $request->all());
})->where('path', '.+');
Thanks for helping out here @jackmu95! I've been swamped the last couple weeks, and a little behind on my tickets.
As of version 1.0 you cannot pass in a request object like this:
$server->outputImage($request);
This because Glide no longer works for just HttpFoundation, but also works for a other response objects.
Instead, I'd recommend doing this:
$server->getImageResponse();
But in order to do that, you'll have to configure a response factory.
I hope to make another screencast outlining how to use version 1.0, because it is a little more confusing.
It seems that I've had 2 issues happening. Firstly the 'public/img' folder was overriding my route.php file, so as soon as I moved the images to the 'storage/app' I was able to use glide. And secondly the $request didn't work, but I have it fixed by not using it. Thanks for the help!
Hello,
I need watermark so I need to update to 1.0. (it was working well in 0.3 thanks to @jackmu95 )
app/Providers/AppServiceProvider.php
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' => $filesystem->getDriver(),
'cache' => $filesystem->getDriver(),
'watermarks' => $filesystem->getDriver(),
'source_path_prefix' => 'photos',
'cache_path_prefix' => 'photos/.cache',
'watermarks_path_prefix' => 'photos/watermarks',
'base_url' => 'photos',
]);
});
}
app/Http/routes.php
Route::get('photos/{path}', function(League\Glide\Server $server, Illuminate\Http\Request $request){
$server->getImageResponse($request, []);
})->where('path', '.+');
But now I have an error:
FileNotFoundException in Server.php line 467: Could not find the image `photos/GET /photos/GM1-509/0.jpg?w=680&h=508&fit=crop HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5
Cache-Control: max-age=0
Connection: keep-alive
Content-Length:
Content-Type:
Cookie: remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d=eyJpdiI6Im5YNXVhWHBVR2ZwVms1eXRcL2FxYnh3PT0iLCJ2YWx1ZSI6InljQ0IrVlE5WjFkdDQyVkliSWZBcmJNdkxjM0dNMEd3UytJUGFrOGdzazBGNUdNejBWUFlPbUtrU0g2UWlcLzVcL1NBejM2Ymo1amw4QkRlOGozQzlrdDZVczdwckcxUVdWbHdoemdRT0RZaEE9IiwibWFjIjoiYjFhNDdlYzY2MDA0NjM3MDExMzlkNTQwNmIyYTkzZmM0M2Y3MjEwNzA2MzY4MmIyZTExNWM0OGQyNjVmYmY0MSJ9; XSRF-TOKEN=eyJpdiI6IlpNT3lCZEpnTzY0REFXS0tGZ0IxeHc9PSIsInZhbHVlIjoiT2VuRXdLTmtGSXVnVVVBUlUrS0I2c1plM0VSRHFYblVaOGhyNTltV0JlU29PdlZkVGw0MjFhblRNcGRFcVpQSkNMc0pIQ2JwY2JBcEp5MTArNmx2NWc9PSIsIm1hYyI6ImI4NTllOTM1NjZmOTI2MDY1MGZiYTc2NDIxNmFkMjY4M2MyZjFkMmRiYTE3NGRmOTBhMDM4NzBhNzEyNzRhNmYifQ==; laravel_session=eyJpdiI6IlJ1XC92V2hVS3JUclFwSFFxYXYxaEZ3PT0iLCJ2YWx1ZSI6InpsbVBXUVIwaEtPRHg1Z0YrOEtybnc5OGQ4WWtpWXdBZkUyYWJHcWVIeng4ZVMrRUoybTI0WVRnYmJYSTVNOUxHVDIwbzcwcG9RMlFvWmErclUycllnPT0iLCJtYWMiOiIwOWVhZDQyNzIzMGY0ZTUyMDA3OTdkMzAyNTk3ZGFlYWM5ZWExMmI1M2YzMTU5OTIyM2QyN2JiOTA5YTNiZWNlIn0=
Host: bimmo.app
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0
For information: Storage photo /home/user/code/bimmo/storage/app/photos/GM1-509/0.jpg Url photo : http://bimmo.app/photos/GM1-509/0.jpg?w=680&h=508&fit=crop
Thanks for your help
I'm not 100% sure, but I think you should remove the "'base_url' => 'photos'," from your service provider.
Thanks but it's not working:
FileNotFoundException in Server.php line 467: Could not find the image `photos/GET /photos/GM1-509/0.jpg?w=680&h=508&fit=crop HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5
Cache-Control: max-age=0
Connection: keep-alive
Content-Length:
Content-Type:
Cookie: remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d=eyJpdiI6Im5YNXVhWHBVR2ZwVms1eXRcL2FxYnh3PT0iLCJ2YWx1ZSI6InljQ0IrVlE5WjFkdDQyVkliSWZBcmJNdkxjM0dNMEd3UytJUGFrOGdzazBGNUdNejBWUFlPbUtrU0g2UWlcLzVcL1NBejM2Ymo1amw4QkRlOGozQzlrdDZVczdwckcxUVdWbHdoemdRT0RZaEE9IiwibWFjIjoiYjFhNDdlYzY2MDA0NjM3MDExMzlkNTQwNmIyYTkzZmM0M2Y3MjEwNzA2MzY4MmIyZTExNWM0OGQyNjVmYmY0MSJ9; XSRF-TOKEN=eyJpdiI6InRCR0NoaEVIM1RPS2ZKMTkxY2NsdEE9PSIsInZhbHVlIjoiMTF6a3NaTGQ4WmFjbW1FRlVDdFdYSHlmTDlQVlR2TUR6dWVRU1V4SnJ0VjVRbHcrWFFKZ1RUVHdDc2U1ZHREaldoQ25yS3JNcmw1bUFHdGhXRzRjakE9PSIsIm1hYyI6IjgyMzA1ZGE1NTI5MmQ2YjdjYzJhYmY2ZTNhMDg4OGQ4ODdmMmQ2NDlkNDNlYzFhMWZmYjJlYmVlNDQwZjY5MzQifQ==; laravel_session=eyJpdiI6IjJOdnlzSnJ5RDd0MXFUb0FlNmM5XC93PT0iLCJ2YWx1ZSI6Ik9cL01aRFdkYSs1b3NBZnpwaFQ0THBQWldZbW0yVEdrQ0ZyR0ZJeEY4V1lcL0h6MW5CbXBNQ0xKalJxaFNnbW5sZUVxOGxpZXVZNEN2Z3Qrem1vajVtaUE9PSIsIm1hYyI6IjE0NThlMDU2NTczZWFiMTQ4Yzk5M2Q4YWI4MTRmNDQ3Zjc4ZTZhOGNhMjA5ZTZlOGRmYzdiNGEyNTkxNTdlZDgifQ==
Host: bimmo.app
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0
Now it's working with Glide 1.0 but I don't use getImageResponse() because it's not working for me :
app/Providers/AppServiceProvider.php
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' => $filesystem->getDriver(),
'cache' => $filesystem->getDriver(),
'watermarks' => $filesystem->getDriver(),
'source_path_prefix' => 'photos',
'cache_path_prefix' => 'photos/.cache',
'watermarks_path_prefix' => 'photos/watermarks',
// 'base_url' => 'photos',
]);
});
}
app/Http/routes.php
Route::get('photos/{path}', function(League\Glide\Server $server, Illuminate\Http\Request $request, $path){
$server->outputImage($path, $request->input());
})->where('path', '.+');
http://bimmo.app/photos/GM1-509/4.jpg?mark=vendu.png&markw=420&markh=400 show me the good image in /home/user/code/bimmo/storage/app/photos/GM1-509/4.jpg with the watermark /home/user/code/bimmo/storage/app/photos/watermarks/vendu.png
show error cannot be displayed because it contains error.
$this->app->bind( 'Illuminate\Contracts\Auth\Registrar', 'App\Services\Registrar' );
$this->app->singleton('League\Glide\Server', function ($app) {
$filesystem = $app->make('Illuminate\Contracts\Filesystem\Filesystem');
return \League\Glide\ServerFactory::create([
'source' => 'uploads/',
'cache' => $filesystem->getDriver(),
'source_path_prefix' => 'images',
'cache_path_prefix' => 'uploads/.rin',
'base_url' => 'img',
]);
});
I've been trying to set up Glide to work with Laravel for a while now, but nothing I've tried worked. Glide 0.3 is well documented when it comes to setting up. Unfortunately, the 1.0 version doesn't give enough information on how to set it up correctly. Have anyone managed to set up the new Glide? Thanks!