Download the PHP package modularavel/cloudflare-stream-video without Composer
On this page you can find all versions of the php package modularavel/cloudflare-stream-video. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download modularavel/cloudflare-stream-video
More information about modularavel/cloudflare-stream-video
Files in modularavel/cloudflare-stream-video
Package cloudflare-stream-video
Short Description Cloudflare Stream Video Package for Laravel Framework
License MIT
Homepage https://github.com/modularavel/cloudflare-stream-video
Informations about the package cloudflare-stream-video
modularavel/cloudflare-stream-video
A Laravel package that provides an idiomatic, strongly typed interface to the Cloudflare Stream Video API. Upload, manage, and stream videos with signed URLs, watermark overlays, and webhook-driven processing — all from within your Laravel application.
Features
- Video Management — Upload (TUS), copy from URL, direct upload, list, get, update, and delete videos
- Signed Playback URLs — HMAC-SHA256 signed tokens for restricted video access
- Watermark Management — Create, list, update, delete watermarks; apply/remove watermarks on videos
- Webhook Integration — Receive Cloudflare Stream processing notifications, process them asynchronously via queued jobs, and broadcast completion events
- Blade Player Component — Responsive iframe embed component with signed URL support
- Artisan Commands — CLI commands for video import, sync, signed URL generation, and watermark management
- Config Publishing — All configuration, views, translations, and assets are publishable
Installation
You can install the package via Composer:
Publishing Resources
You may publish all of the package's resources at once:
Or, publish each resource individually:
Configuration
After publishing, edit config/cloudflare-stream-video.php to configure your Cloudflare account.
Migrations
This will create:
cloudflare_stream_videos— Local cache of Cloudflare Stream videoscloudflare_stream_webhooks— Audit log for webhook deliveries
Views
Translations
Public Assets
Configuration
After publishing the config file, edit config/cloudflare-stream-video.php to match your Cloudflare account credentials and preferences. Environment variables (with CLOUDFLARE_STREAM_ prefix) take precedence over config file values.
🔑 Required Settings
| 🔧 Key | 🌿 Env Variable | 📝 Description |
|---|---|---|
account_id |
CLOUDFLARE_STREAM_ACCOUNT_ID |
Your Cloudflare account identifier |
api_token |
CLOUDFLARE_STREAM_API_TOKEN |
API token with "Stream Edit" or "Stream Read" permissions |
⚙️ Optional Settings
| 🔧 Key | 🌿 Env Variable | 💡 Default | 📝 Description |
|---|---|---|---|
timeout |
CLOUDFLARE_STREAM_TIMEOUT |
120 |
HTTP request timeout in seconds |
defaults |
— | [] |
Default key-value pairs merged into every API request body |
require_signed_urls |
CLOUDFLARE_STREAM_REQUIRE_SIGNED_URLS |
false |
Whether videos require signed URLs for playback |
signing_key |
CLOUDFLARE_STREAM_SIGNING_KEY |
'' |
HMAC-SHA256 signing key for signed URL generation |
customer_domain |
CLOUDFLARE_STREAM_CUSTOMER_DOMAIN |
'' |
Custom Cloudflare Stream customer domain for signed URLs |
watermark.default_position |
— | 'bottom-right' |
Default watermark position on the video frame |
watermark.default_opacity |
— | 1.0 |
Default watermark opacity (0.0–1.0) |
watermark.default_width |
— | 0 |
Default watermark width in pixels |
watermark.default_height |
— | 0 |
Default watermark height in pixels |
webhook.secret |
CLOUDFLARE_STREAM_WEBHOOK_SECRET |
'' |
Secret used to verify incoming webhook signatures |
webhook.route |
CLOUDFLARE_STREAM_WEBHOOK_ROUTE |
'cloudflare-stream-video/webhook' |
Route path for receiving webhook notifications |
🔐 Environment Example
Usage
Basic Video Operations
The CloudflareStreamVideo facade (or inject CloudflareStreamVideoInterface) provides the full API surface.
Upload a Video (TUS)
Copy a Video from a URL
Create a Direct Upload
List Videos
Get a Single Video
Update a Video
Delete a Video
Signed URLs
When a signing key is configured, you can generate signed playback URLs and tokens.
Watermarking
Watermarks are overlay images (typically PNG or SVG with transparency) that can be applied to videos during playback. They are managed per-account and associated with videos via their UID.
Create a Watermark
List All Watermarks
Get a Single Watermark
Update a Watermark
Delete a Watermark
Apply a Watermark to a Video
Remove a Watermark from a Video
Webhook Integration
Cloudflare Stream can send webhook notifications when video processing events occur (e.g. video.ready, video.error). The package provides a webhook endpoint, a background job for async processing, and an event for broadcasting completion.
Setup
-
Configure the webhook secret in your
.env: -
Configure the webhook route (optional, defaults to
cloudflare-stream-video/webhook): - Register the webhook URL in the Cloudflare Stream dashboard under Notifications -> Webhooks. The URL will be:
Handling Webhook Events
The package dispatches a StreamVideoProcessed event whenever a webhook is received. You can listen for this event in your application:
Webhook Payload Structure
Cloudflare Stream sends webhook payloads with the following structure:
Webhook Signature Verification
The webhook controller verifies incoming requests using HMAC-SHA256 signatures. The signature is sent in the X-Cloudflare-Signature header as a hex-encoded HMAC digest of the raw request body.
If no CLOUDFLARE_STREAM_WEBHOOK_SECRET is configured, signature verification is skipped (not recommended for production).
Webhook Database Table
The package includes a migration that creates the cloudflare_stream_webhooks table for auditing webhook deliveries:
The table stores:
event_type— the Cloudflare Stream event typevideo_uid— the video identifier from the payloadpayload— the raw JSON payload (nullable)processed— boolean flag indicating whether the background job has processed the webhook
Blade Player Component
The package includes a responsive Blade component for embedding Cloudflare Stream videos.
Basic Usage
Signed Mode
Custom Dimensions and Styling
The component renders a responsive iframe wrapper with the Cloudflare Stream embed player. When signed is true, the component generates a signed embed URL using the configured signing key.
Artisan Commands
Placeholder Command
A basic command that confirms the package is installed and working.
Import Video from URL
Sync Videos
Syncs videos from Cloudflare Stream with your local database.
Generate Signed URL
Watermark Management
🧪 Testes
O pacote conta com 86 testes e 150 assertions usando Pest PHP:
📚 Contribute
We welcome your contributions! Please check out our contributing guide for details.
🔒 Security Policy
Report security vulnerabilities responsibly through our security policy.
👨💻 Author
📄 License
This project is licensed under the MIT License — see the LICENSE.md file for details.
✨ Support
If you've found this package useful, please ⭐ the repository to show your support!
Made with ❤️ by Modularavel
Version 0.1.0
