novay/bunny-secrets 问题修复 & 功能扩展

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

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

novay/bunny-secrets

最新稳定版本:1.01

Composer 安装命令:

composer require novay/bunny-secrets

包简介

Laravel package for BunnyCDN secrets management and filesystem integration with Borneo Secrets Manager.

README 文档

README

This Laravel package provides a seamless integration with BunnyCDN for both secret management and filesystem operations. It allows you to easily upload, delete, and retrieve files from your BunnyCDN Storage Zone while securely managing your API keys.

Key Features

  • Secrets Management: Fetch and store API keys and other secrets from an external service.
  • Flysystem Driver: Full integration with Laravel's filesystem (leveraging platformcommunity/flysystem-bunnycdn).
  • File Operations: Effortlessly upload, retrieve public URLs, and delete files on BunnyCDN.
  • ImageKit Support: Optionally, transform image URLs to utilize BunnyCDN's ImageKit.io features.
  • Service Provider: Automatic configuration for Laravel 10.0 and above.

Requirements

  • PHP: ^8.2
  • Laravel Framework: ^10.0
  • API from Borneo Secrets Manager

Installation

You can install the package via Composer:

composer require novay/bunny-secrets

After installation, the BunnySecretServiceProvider will be automatically discovered and registered by Laravel.

Configuration

To publish the bunnycdn.php configuration file, run the following Artisan command:

php artisan vendor:publish --tag=bunny-secrets-config

The configuration file will be located at config/bunnycdn.php. Make sure to populate the necessary environment variables in your .env file, such as BUNNYCDN_API_KEY and BUNNYCDN_STORAGE_ZONE.

Example .env configuration:

# BunnyCDN Storage Zone & API Key
BUNNYCDN_STORAGE_ZONE="your-storage-zone-name"
BUNNYCDN_API_KEY="your-api-key"
BUNNYCDN_REGION="sg" # e.g., 'de', 'ny', 'la', 'sao', 'syd', 'singapore', 'london', 'tokyo'
BUNNYCDN_CDN_URL="https://your-cdn-hostname.b-cdn.net"

# Secret API Service
SECRET_URI="https://api.your-secret-service.com"
SECRET_KEY="your-secret-service-api-key"

# Secret File & Key
BUNNY_SECRET_FILE="bunny_api_key.txt"
BUNNY_SECRET_KEY="bunny-secrets-pass"

Usage

You can access the package's functionality through the BunnySecret Facade.

use Novay\BunnySecret\BunnySecret;
use Illuminate\Http\UploadedFile;

// Upload a file to BunnyCDN
$filePath = BunnySecret::uploadCDN(
  file: $this->photo, 
  path: 'berau/sudik/avatar', 
  filename: str()->slug('filename').'-'.uniqid()
);
if ($filePath === false) {
  throw new \Exception("Failed to upload photo to CDN.");
}

// Get the public URL of the file
$fileUrl = BunnySecret::showCDN($filePath);
echo "Public file URL: " . $fileUrl;

// Transform an image URL with ImageKit (if configured)
$imageUrl = 'https://s3-url/images/my-image.jpg';
$resizedImageUrl = BunnySecret::imageKit($imageUrl, 800);
echo "Transformed image URL: " . $resizedImageUrl;

// Delete a file
$isDeleted = BunnySecret::deleteCDN(filePath: $filePath);
if ($isDeleted) {
    echo "File deleted successfully.";
}

Accessing via the Storage Facade

Since this package provides a custom Flysystem driver, you can also use Laravel's Storage Facade with the bunnycdn disk.

use Illuminate\Support\Facades\Storage;
use Illuminate\Http\UploadedFile;

// Upload a file
$fileContent = file_get_contents('path/to/your/local/file.jpg');
Storage::disk('bunnycdn')->put('images/file.jpg', $fileContent);

// Get a public URL
$url = Storage::disk('bunnycdn')->url('images/file.jpg');

// Delete a file
Storage::disk('bunnycdn')->delete('images/file.jpg');

License

This package is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固