onurozdogan/cloudflare-image-api
Composer 安装命令:
composer require onurozdogan/cloudflare-image-api
包简介
Cloudflare Image API PHP Library
README 文档
README
This package is the code that I used in a single project and has been edited to make it usable in many projects. Since I need these functions in more than one project, I have prepared and presented them as a package.
Requirement
Laravel >= 9
Livewire >= 3
Php >= 8.0
Cloudflare Account
Installation
You can install the package via composer:
$ composer require onurozdogan/cloudflare-image-api
Usage
Configuration
First, you need to add the following configuration to your .env file.
CLOUDFLARE_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
CLOUDFLARE_ACCOUNT_ID="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Upload Image
First parameter is image file, second parameter is image name.
$image = CloudflareImageApi::upload($request->file('image'), $name);
Response if image uploaded successfully:
if ($image->getStatusCode() == 200) { // Check image uploaded successfully
$img=$image->getData(); // Get image data
$db->image = $img->photoId; // Save image id to database
}
Response if image uploaded failed:
if ($image->getStatusCode() != 200) { // Check image uploaded failed
$error=$image->getData(); // Get error message
return response()->json($error, 400); // Return error message (This is an example, you can use it as you wish)
}
Update Image
First parameter is image id (old image), second parameter is new image file, third parameter is image name
$image = CloudflareImageApi::update($db->image, $request->file('image'), $name);
Response if image updated successfully:
if ($image->getStatusCode() == 200) { // Check image updated successfully
$img=$image->getData(); // Get image data
$db->image = $img->photoId; // Save image id to database
}
Response if image updated failed:
if ($image->getStatusCode() != 200) { // Check image updated failed
$error=$image->getData(); // Get error message
return response()->json($error, 400); // Return error message (This is an example, you can use it as you wish)
}
Delete Image
$image = CloudflareImageApi::delete($db->image);
Response if image deleted failed:
if ($image->getStatusCode() != 200) { // Check image deleted failed
$error=$image->getData(); // Get error message
return response()->json($error, 400); // Return error message (This is an example, you can use it as you wish)
}
Get Image In Blade
<img src="https://imagedelivery.net/your-account-hash/{{ $blog->image }}/public" alt="{{ $blog->title }}" loading="lazy">
Security
If you discover any security related issues, please contact me via https://onurozdogan.com. All security vulnerabilities will be fixed as soon as possible.
License
The MIT License (MIT). Please see License File for more information.
onurozdogan/cloudflare-image-api 适用场景与选型建议
onurozdogan/cloudflare-image-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 247 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「image」 「api」 「library」 「laravel」 「cloudflare」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 onurozdogan/cloudflare-image-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 onurozdogan/cloudflare-image-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 onurozdogan/cloudflare-image-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
A PSR-7 compatible library for making CRUD API endpoints
The Yii2 extension uses jQuery PrettyPhoto and OwlCarousel js and makes image galary from php array of structure defined.
Yii2 prettyPhoto image galary widget uses Lightbox view control jquery.prettyphoto.js
Alfabank REST API integration
统计信息
- 总下载量: 247
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-10