PHP code example of kaolasz / think-glide

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

    

kaolasz / think-glide example snippets


    return [
        //...
    
        \think\glide\middleware\Glide::class
    ];
    

php think glide:config 

echo glide_url('user.jpg', ['w' => 100, 'h' => 100]);
或
echo app('glide_builder')->getUrl('user.jpg', ['w' => 100, 'h' => 100]);

//你会得到如下链接:/images/user.jpg?w=100&h=100&sign=af3dc18fc6bfb2afb521e587c348b904

return [
    //...

    'onException' => function(\Exception $exception, $request, $server){
    
        if ($exception instanceof \League\Glide\Signatures\SignatureException) {
            $response = response('签名错误', 403);
        } else {
            $response = response(sprintf('你访问的资源 "%s" 不存在', $request->path()), 404);
        }
        
        return $response;
    }
])