【问题标题】:Add 'Gregwar's Image class' to Laravel将“Gregwar 的图像类”添加到 Laravel
【发布时间】:2014-04-14 00:36:13
【问题描述】:

我想将这个类添加到 laravel - https://github.com/Gregwar/Image

有“与作曲家一起使用”-我将此行添加到 composer.json

"gregwar/image": "dev-master"

我被跑了:

php artisan optimize
composer dump-autoload

但是如果我想使用这个类 - 有这个错误:

Class 'Image' not found 

类(由 composer)安装在根目录下:vendor/gregwar/...

【问题讨论】:

    标签: php git class laravel


    【解决方案1】:

    正如自述文件所说,您必须使用其命名空间“要求”它:

    use Gregwar\Image\Image;
    

    所以你的代码应该是这样的:

    <?php
    
    use Gregwar\Image\Image;
    
    echo Image::open('test.png')
        ->sepia()
        ->jpeg();
    

    【讨论】:

    • 如果我放置命名空间 - 得到错误语法错误,意外的 'use' (T_USE)'
    • 'use' 需要在定义任何类之前放在脚本的顶部
    • 请分享您的源代码。您将其添加到错误的位置。
    猜你喜欢
    • 2017-11-30
    • 2013-08-11
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    • 2015-03-10
    • 2022-06-19
    • 2022-01-18
    • 2013-01-18
    相关资源
    最近更新 更多