Download the PHP package benbjurstrom/cloudflare-images-php without Composer
On this page you can find all versions of the php package benbjurstrom/cloudflare-images-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download benbjurstrom/cloudflare-images-php
More information about benbjurstrom/cloudflare-images-php
Files in benbjurstrom/cloudflare-images-php
Package cloudflare-images-php
Short Description A PHP client for the Cloudflare Images API
License MIT
Informations about the package cloudflare-images-php
Cloudflare Images PHP client
This is a framework-agnostic PHP client for Cloudflare Images built on the amazing Saloon v2 🤠 library.
Table of contents
- Quick Start
- Using with Laravel
- Response Data
- Image Metadata
- Private Images
- Custom IDs
- Image Methods
- Variant Methods
🚀 Quick start
Install with composer.
Create a new api instance.
Then use it to get details about an existing image.
Or to upload a new image from an image string.
Or generate a one time upload url that lets your users upload images directly to cloudflare without exposing your api key.
You can find more information about direct creator uploads in the Cloudflare Docs.
Using with Laravel
Begin by adding your credentials to your services config file.
Bind the CloudflareImages
class in a service provider.
`
And use anywhere in your application.
Test your integration using Saloon's amazing response recording.
Response Data
All responses are returned as data objects. Detailed information can be found by inspecting the following class properties:
Image Metadata
Cloudflare allows you attach a modifiable key-value store to your images. To attach metadata to your image chain withMetadata($metadata)
onto your api instance before calling the create
, createFromUrl
, update
, or getUploadUrl
methods. For example:
Private Images
Cloudflare allows you to configure an image to only be accessible with a signed URL token. To make an image private chain private(true)
onto your api instance before calling the create
, createFromUrl
, update
, or getUploadUrl
methods. For example:
To generate signatures instantiate your api with the optional signing key parameter and then pass the url you want to sign to the signUrl
method.
You can find more information about serving private images in the Cloudflare documentation.
Custom IDs
Cloudflare allows you to configure a custom identifier if you wish. To do so chain withCustomId($id)
onto your api instance before calling the create
, createFromUrl
, or getUploadUrl
methods. For example:
Note that images with a custom ID cannot be made private. You can find more information about custom ids in the Cloudflare documentation.
Available Image Methods
get()
Use to get details about an image such as its file name, metadata, and available variants. Returns an ImageData object.
list()
Use to get a paginated list of images. Returns an ImagesData object.
create()
Use to upload an image from an image string. Returns an ImageData object.
createFromUrl()
Use to add an image to Cloudflare from a given url. Returns an ImageData object.
update()
Use to update an image's metadata or privacy setting. Returns an ImageData object.
⚠️ WARNING - Modifying an image's privacy setting will change the image's identifier.
delete()
Use to delete an image. Returns a boolean.
getUploadUrl()
Use to generate a one time upload url that lets your users upload images directly to cloudflare without exposing your api key. Returns an UploadUrlData object.
You can find more information about direct creator uploads in the Cloudflare Docs.
Variant Methods
list()
Use to get a list of all variants. Returns a VariantsData object.