我正在尝试将此库启用到我的本地环境。
http://glide.thephpleague.com/1.0/config/integrations/laravel/
Laravel当前版本为 5.5
gd2
已在wamp扩展中启用。
我找不到问题出在哪里。
路径正确,图像已经存在其中。
请查看以下服务器配置代码:
$server = ServerFactory::create([
'response' => new LaravelResponseFactory(app('request')),
'source' => $source,
//'cache' => new Filesystem(new Adapter('../storage/app/cache/')),
'cache' => $cache,
'cache_path_prefix' => '.cache',
'base_url' => 'transform-img',
]);
现在我使用这个。
return $server->getImageResponse($path, request()->all());
它没有给出任何错误。
当我使用dd()
时,我得到了这个响应。
StreamedResponse {#1151 ▼
#callback: Closure {#1177 ▶}
#streamed: false
-headersSent: false
+headers: ResponseHeaderBag {#1176 ▶}
#content: null
#version: "1.0"
#statusCode: 200
#statusText: "OK"
#charset: null
}
回调闭包:
#callback: Closure {#1252 ▼
class: "League\Glide\Responses\SymfonyResponseFactory"
this: LaravelResponseFactory {#1231 …}
use: {▼
$stream: stream resource @543 ▼
timed_out: false
blocked: true
eof: false
wrapper_type: "plainfile"
stream_type: "STDIO"
mode: "rb"
unread_bytes: 0
seekable: true
uri: "D:\wamp\www\Bankrolla\storage\app/public\.cache/img/logo_no_text.png/32c8e67d979eab40a7ef6d1854f1f7cc"
options: []
}
}
file: "D:\wamp\www\Bankrolla\vendor\league\glide-symfony\src\Responses\SymfonyResponseFactory.php"
line: "48 to 54"
}
虽然statusCode显示为200
,并且没有文件未找到的错误,但当我导航时它仍然不会加载任何图像,而是在浏览器上显示占位符。
可能出了什么问题?如果我尝试用任何其他随机字符串替换图像名称,则会收到有关找不到图像的错误。所以这意味着它确实找到了该图像。尽管无法呈现该图像。
我已经搜索过谷歌,并在他们的GitHub评论中搜索过,但找不到与我的问题类似的问题。
如果我直接加载它,我只会得到一个空白页面/图像。
我还查看了缓存目录,其中包括文件,这些文件的尺寸已调整大小。因此,即使生成缓存文件,我也不确定哪里出了问题。
也许我在这里漏掉了什么?
更新
$source
变量的值:
Filesystem {#1225 ▼
#adapter: Local {#1226 ▼
#pathSeparator: "\"
#permissionMap: array:2 [▼
"file" => array:2 [▼
"public" => 420
"private" => 384
]
"dir" => array:2 [▼
"public" => 493
"private" => 448
]
]
#writeFlags: 2
-linkHandling: 2
#pathPrefix: "D:\wamp\www\Bankrolla\storage\app/public\"
}
#plugins: []
#config: Config {#1229 ▼
#settings: []
#fallback: null
}
}
我的公共目录中的存储目录(它是原始存储的符号链接)
Laravel 的存储目录
我从中调用此 URL。
{localhostDomainHere}/image/img/logo_no_text.png?w=100&h=100&fit=crop-center