php 如何在laravel 10中正确配置cloudinary?

jvidinwx  于 2023-09-29  发布在  PHP
关注(0)|答案(1)|浏览(117)

Cloudinary正在变得未定义。我正在使用laravel 10和“cloudinary-labs/cloudinary-laravel”:“^2.0”,
我已经安装了cloudinary by
composer require cloudinary-labs/cloudinary-laravel
并发布云配置

php artisan vendor:publish --provider="CloudinaryLabs\CloudinaryLaravel\CloudinaryServiceProvider"

并在config/api.php中添加

'providers' => [
    ...
    CloudinaryLabs\CloudinaryLaravel\CloudinaryServiceProvider::class,
],

'aliases' => [
    ...
    'Cloudinary' => CloudinaryLabs\CloudinaryLaravel\Facades\Cloudinary::class,
],

还提供了我的API密钥,云名称在.env文件中。
这是我的控制器

<?php

    namespace App\Http\Controllers\Api;
    use App\Http\Controllers\Controller;
    use Illuminate\Http\Request;
    use CloudinaryLabs\CloudinaryLaravel\Facades\Cloudinary;
 
    class FileUploadController extends Controller
    {
        public function storeUploads(Request $request)
        {
        $image = $request->file('image');
        if($image){
            $cloudinary = new Cloudinary();
        }
        
    }
}

这里是我得到未定义的Cloudinary

yvgpqqbh

yvgpqqbh1#

我解决了这个问题。我的问题是该高速缓存。当我重新启动IDE时,它正在工作。

相关问题