shorunke/cloudinary 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shorunke/cloudinary

Composer 安装命令:

composer require shorunke/cloudinary

包简介

This Package Helps Easily integrate Cloudinary Api for Easy Use of Files storage

README 文档

README

Latest Version on Packagist Total Downloads

Easily integrate Cloudinary into your Laravel application. This package provides a simple and expressive way to upload, rename, delete, and manage media files on Cloudinary, with full support for Laravel 12.

✨ Features

  • Upload images or files to Cloudinary
  • Delete files by public ID
  • Move/Rename files
  • Extract Cloudinary public ID from URL
  • Simple configuration and service binding
  • Optional facade for global access

🚀 Installation

Install the package via Composer:

composer require shorunke/cloudinary

Then, publish the config and service class:

php artisan cloudinary:install

🔧 Configuration

After installation, a config/cloudinary.php file will be published. Add your environment variables to your .env file:

    CLOUDINARY_CLOUD_NAME=your-cloud-name
    CLOUDINARY_API_KEY=your-api-key
    CLOUDINARY_API_SECRET=your-api-secret
    CLOUDINARY_SECURE_URL=true

🛠️ Usage

Using Dependency Injection

    use Shorunke\Cloudinary\CloudinaryService;

    public function store(Request $request, CloudinaryService $cloudinary)
    {
        $result = $cloudinary->upload($request->file('image')->getPathname(), 'uploads');
        return response()->json($result);

        //to get the secure url 
        $secure = $result['secure_url'];
    }

Using the Facade First, ensure the facade is registered in config/app.php (or via auto-discovery):

'aliases' => [
    'Cloudinary' => Shorunke\Cloudinary\Facades\Cloudinary::class,
],

Then use it globally:

use Cloudinary;

Cloudinary::upload('path/to/file.jpg', 'uploads');

📦 Available Methods

// Upload a file
upload(string $filePath, string $folder, ?string $publicId = null, array $options = [])

// Delete a file
delete(string $publicId, array $options = [])

// Move/Rename a file
move(string $fromPublicId, string $toPublicId, array $options = [])

// Extract public ID from a full Cloudinary URL
$publicId = extractCloudinaryPublicId(string $url)

$url = $result['secure_url'];

📚 Credits

Developed by Shorunke Olamilekan Email : Shorunke99@gmail.com Powered by Cloudinary PHP SDK

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-04-07