Php 干预图像Laravel 5.1

Php 干预图像Laravel 5.1,php,laravel,Php,Laravel,我尝试调整img的大小,我执行以下步骤: 更新编写器: "intervention/image": "dev-master", 下一步在app/config中添加行 Intervention\Image\ImageServiceProvider::class, 'Image' => Intervention\Image\Facades\Image::class 在我的控制器中: use Intervention\Image\Image as Img; Img:

我尝试调整img的大小,我执行以下步骤: 更新编写器:

"intervention/image": "dev-master",
下一步在app/config中添加行

     Intervention\Image\ImageServiceProvider::class,
    'Image'     => Intervention\Image\Facades\Image::class
在我的控制器中:

use Intervention\Image\Image as Img;
Img::make($destination_path . $filename)->resize(200, 200)->save($destination_path . $filename);
这是一个错误:

Call to undefined method Intervention\Image\Image::make()
全功能laravel 5.1

尝试:

1) 检查应用程序(默认情况下)文件夹中是否有名为Image的模型

(二)

a) 放置
使用图像到控制器的顶部

b) 扔掉这个:使用interference\Image\Image作为Img


c) 只需使用这个:
Image::make(
而不是Img:make(

我自己也有同样的问题。在谷歌搜索了很多次之后,我发现了Laravel 5.1的特定功能

简单地改变

use Intervention\Image\Image;


最简单的方法是使用facade而不是provider。

因此,不是:

use Intervention\Image\Image as Img;
就这样说吧:

use Image;
然后你可以这样使用它:

Image::make($destination_path . $filename)->resize(200, 200)->save($destination_path . $filename);

只需按照以下步骤操作:

1) 从根目录打开composer.json文件

      "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "laravel/socialite": "^2.0",

        // add these lines
        "illuminate/html": "5.*",
        "intervention/image": "dev-master"
    }
2) 现在运行composerupdate命令来获取这些包

 composer update
3) 打开config/app.php文件

a) 使用以下行更新提供程序数组

     'providers' => [

        // add this line at the bottom  
        Intervention\Image\ImageServiceProvider::class
        ]
'aliases' => [
         // add this line at the bottom 
        'Image'     => Intervention\Image\Facades\Image::class
        ],
b) 使用以下行更新别名数组

     'providers' => [

        // add this line at the bottom  
        Intervention\Image\ImageServiceProvider::class
        ]
'aliases' => [
         // add this line at the bottom 
        'Image'     => Intervention\Image\Facades\Image::class
        ],
4) 你完了

请参见此处的详细信息:

打开:config/app.php

添加到阵列别名:

'Image' => Intervention\Image\ImageManagerStatic::class,
在控制器中:

use Image;

试着用
Image::make(…..
替换控制器中的代码,你的facade应该使Image类可用,如果不可用,那么改为
\Image::make(…
),然后它会在Container.php行734中说明
ReflectionException:class Image不存在