├── LICENSE ├── README.md ├── composer.json ├── config └── cloudflare_images.php └── src ├── CloudflareApi.php ├── CloudflareImagesServiceProvider.php ├── Exceptions ├── CloudflareImageNotFound.php ├── CloudflareImagesApiException.php ├── CloudflareImagesApiUnexpectedError.php ├── CloudflareSignatureTokenNotProvided.php ├── CloudflareSignedUrlNotSupportedForCustomIds.php ├── IncorrectKeyOrAccountProvided.php ├── NoImageDeliveryUrlProvided.php └── NoKeyOrAccountProvided.php ├── Facades └── CloudflareApi.php ├── Helpers └── SignedUrlGenerator.php ├── Http ├── Clients │ ├── ImagesApiClient.php │ └── ImagesVariantsApiClient.php ├── Entities │ ├── ArrayableEntity.php │ ├── DirectUploadInfo.php │ ├── Image.php │ ├── ImageVariant.php │ └── ImageVariants.php └── Responses │ ├── BaseResponse.php │ ├── DetailsResponse.php │ └── ListResponse.php └── Testing └── Fakes ├── ImagesApiClientFake.php └── ImagesVariantsApiClientFake.php /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 godundmytro 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cloudflare Images 2 | 3 | Provides access to Cloudflare Images API for Laravel projects 4 | 5 | [![Stable Version][badge_stable]][link_packagist] 6 | [![Unstable Version][badge_unstable]][link_packagist] 7 | [![Total Downloads][badge_downloads]][link_packagist] 8 | [![License][badge_license]][link_license] 9 | 10 | ## Table of contents 11 | 12 | * [Installation](#installation) 13 | * [Configuration](#configuration) 14 | * [Using](#using) 15 | 16 | ## Installation 17 | 18 | To get the latest version of `Laravel CloudflareImages`, simply require the project using [Composer](https://getcomposer.org): 19 | 20 | ```bash 21 | $ composer require dedmytro/laravel-cloudflare-images 22 | ``` 23 | 24 | Or manually update `require` block of `composer.json` and run `composer update`. 25 | 26 | ```json 27 | { 28 | "require": { 29 | "dedmytro/laravel-cloudflare-images": "^0.2" 30 | } 31 | } 32 | ``` 33 | 34 | ## Configuration 35 | 36 | Add environment variables to your .env file: 37 | 38 | ```dotenv 39 | CLOUDFLARE_IMAGES_ACCOUNT='your-account-id' 40 | CLOUDFLARE_IMAGES_KEY='your-api-key' 41 | CLOUDFLARE_IMAGES_DELIVERY_URL='https://imagedelivery.net/ZWd9g1K8vvvVv_Yyyy_XXX' 42 | CLOUDFLARE_IMAGES_DEFAULT_VARIATION='your-default-variation' 43 | CLOUDFLARE_IMAGES_SIGNATURE_TOKEN='your-signature-token' 44 | ``` 45 | 46 | or publish config and set up vars there 47 | 48 | ```php 49 | return [ 50 | 'account'=> env('CLOUDFLARE_IMAGES_ACCOUNT'), 51 | 'key'=> env('CLOUDFLARE_IMAGES_KEY'), 52 | 'delivery_url' => env('CLOUDFLARE_IMAGES_DELIVERY_URL'), 53 | 'default_variation' => env('CLOUDFLARE_IMAGES_DEFAULT_VARIATION'), 54 | 'signature_token' => env('CLOUDFLARE_IMAGES_SIGNATURE_TOKEN') 55 | ]; 56 | ``` 57 | 58 | `CLOUDFLARE_IMAGES_KEY` - is an `API Token`. To create a new one go to [User Api Tokens](https://dash.cloudflare.com/profile/api-tokens) on Cloudflare dashboard 59 | 60 | `CLOUDFLARE_IMAGES_ACCOUNT` - is an `Account ID` on the Overview page 61 | 62 | `CLOUDFLARE_IMAGES_DELIVERY_URL` - is an `Image Delivery URL` on the Overview page 63 | 64 | `CLOUDFLARE_IMAGES_DEFAULT_VARIATION` - is a variation on the Variants page 65 | 66 | `CLOUDFLARE_IMAGES_SIGNATURE_TOKEN` - is a token from the Images -> Keys page 67 | 68 | 69 | ## Using 70 | 71 | ### Direct upload 72 | 73 | The Direct upload is feature of Cloudflare Images to upload image directly from frontend but without sharing your api key. Once you get this url you can use 74 | inside your html 75 | 76 | `