使用干预时找不到图像类 [英] Image class not found when using Intervention
问题描述
我已经安装了Laravel 5.2和Intervention,现在在项目的composer.json文件中.
I have installed Laravel 5.2 and Intervention, this is now in the composer.json file in the project.
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"intervention/image": "^2.3"
},
在阅读了教程之后,它提到了Image.php文件,一旦安装了Intervention,它应该位于项目内的config文件夹中.我相信我已经正确安装了干预,但是当我尝试使用干预功能时,它不起作用.
After reading tutorials, it mentions an Image.php file that should be in the config folder inside the project once you have installed Intervention. I believe I have installed Intervention correctly but when I try to use the Intervention functions it does not work.
当我尝试使用此行代码时,出现此错误
When I try to use this line of code I get this error
$resizedImg = Image::make($path)->resize(200,200);
C:\xampp\htdocs\socialNet\vendor\laravel\framework\src\Illuminate\Container\Container.php line 738:
类图片不存在
在我正在使用此功能的文件中,我包含此Use语句
and in the file I am using this function I include this Use statement
use Intervention\Image\Facades\Image as Image;
推荐答案
在您的app.php中将此添加到您的 aliases
:
In your app.php Add this in your aliases
:
'Image' => Intervention\Image\Facades\Image::class,
以及您的提供商
Intervention\Image\ImageServiceProvider::class,
别忘了在此之后执行 php artisan config:cache
.
这篇关于使用干预时找不到图像类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!