phico / cdn
Lightweight CDN support for Phico
dev-main
2024-08-04 18:47 UTC
Requires
- php: ^8.0
- aws/aws-sdk-php: ^3.317
- phico/filesystem: dev-main
- phico/http-client: dev-main
Requires (Dev)
- pestphp/pest: ^2.34
- phpstan/phpstan: ^1.11
This package is auto-updated.
Last update: 2024-11-06 12:27:43 UTC
README
Lightweight CDN support for Phico
Installation
Using composer
composer require phico/cdn
Usage
CDN provides quick and simple access to AWS S3 and Cloudflare R2 private CDNs.
Objects
// put a local file on the cdn $cdn->put('path/to/local/file.txt', '/path/on/cdn/file.txt'); // retrieve the file content $content = $this->cdn->get('/path/on/cdn/file.txt'); // delete the file $cdn->delete('/path/on/cdn/file.txt');
Switching buckets
If you have connected with the necessary permissions you can switch buckets.
$cdn->bucket('other-bucket')->put('local/file.txt', 'uploads/file.txt'); $cdn->bucket('backup-bucket')->put('local/file.txt', 'uploads/file.txt');
Buckets
If you have connected with the necessary permissions you can manage buckets.
// list all buckets $array = $cdn->buckets(); // create a bucket on the cdn $cdn->bucket('tmp')->create(); // list objects in the bucket $array = $cdn->bucket('tmp')->list(); // switching a bucket will be remembered so the above two lines could be shortened to $array = $cdn->bucket('tmp')->create()->list(); // delete the bucket from the cdn $cdn->bucket('tmp')->delete();
Issues
If you discover any bugs or issues with behaviour or performance please create an issue, and if you are able a pull request with a fix.
Please make sure to update tests as appropriate.
For major changes, please open an issue first to discuss what you would like to change.