weboptic / flysystem-bunnycdn
BunnyCDN 的 Flysystem 适配器
Requires
- ext-json: *
- guzzlehttp/guzzle: ^7.4
- league/flysystem: ^3.0
Requires (Dev)
- fzaninotto/faker: ^1.5
- league/flysystem-adapter-test-utilities: ^3
- league/flysystem-memory: ^3.0
- mockery/mockery: ^1.3
- phpunit/phpunit: @stable
This package is auto-updated.
Last update: 2024-09-15 20:27:01 UTC
README
BunnyCDN 存储的 Flysystem 适配器
⚠️ 注意 – 破坏性变更
⚠️ (21/Feb/22) 由于上游 BunnyCDNStorage 客户端有一段时间没有更新,继续使用已不再可行。对于所有更新,只需将
BunnyCDNStorage
更改为BunnyCDNClient
并重新导入即可。⚠️
安装
要安装 flysystem-bunnycdn
,需要不带有版本约束的包。这应该与您的 FlySystem 版本(v1、v2、v3 等)相匹配。
composer require platformcommunity/flysystem-bunnycdn "*"
使用方法
use BunnyCDN\Storage\BunnyCDNClient; use League\Flysystem\Filesystem; use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNAdapter; use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNRegion; $adapter = new BunnyCDNAdapter( new BunnyCDNClient( 'storage-zone', 'api-key', BunnyCDNRegion::FALKENSTEIN ) ); $filesystem = new Filesystem($adapter);
使用拉取区域
要使 BunnyCDN 适配器发布到公共 CDN 位置,您需要连接到您的 BunnyCDN 存储区域的“拉取区域”。将您的拉取区域的完整 URL 前缀(包括 http://
/https://
)添加到如下所示的 BunnyCDNAdapter 参数中。
use BunnyCDN\Storage\BunnyCDNClient; use League\Flysystem\Filesystem; use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNAdapter; use PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNRegion; $adapter = new BunnyCDNAdapter( new BunnyCDNClient( 'storage-zone', 'api-key', BunnyCDNRegion::FALKENSTEIN ), 'https://testing.b-cdn.net/' # Pull Zone URL ); $filesystem = new Filesystem($adapter);
注意:如果您在拉取区域中配置了自己的域名,您也可以使用它。
一旦添加您的拉取区域,您可以使用 ->getUrl($path)
,或者在 Laravel 中使用 ->url($path)
命令来获取 BunnyCDN 资产的完全合格公共 URL。
Laravel 9 中的使用
有关如何在 Laravel 9 中使用 flysystem-bunnycdn
的指南,请参考以下链接
https://blog.sinn.io/bunny-net-php-flysystem-v3/#usage-in-laravel-9
区域
有关完整区域列表,请访问BunnyCDN API 文档页面。
flysystem-bunnycdn
还在每个区域中包含常量,这些常量位于 PlatformCommunity\Flysystem\BunnyCDN\BunnyCDNRegion
中。
区域列表
BunnyCDNRegion::FALKENSTEIN = 'de'; BunnyCDNRegion::NEW_YORK = 'ny'; BunnyCDNRegion::LOS_ANGELAS = 'la'; BunnyCDNRegion::SINGAPORE = 'sg'; BunnyCDNRegion::SYDNEY = 'syd'; BuunyCDNRegion::UNITED_KINGDOM = 'uk';
贡献
欢迎拉取请求。请随时提出任何问题作为讨论点。
许可证
Bunny.net 的 Flysystem 适配器采用 MIT 许可证。