Manage Cloudflare Stream with ease by using this handy PHP API wrapper. The laravel-cloudflare-stream package gives ability to...
- ✓ List your videos
- optionally using parameters to filter results
- after
- before
- include_counts
- search
- limit
- asc
- status
- optionally using parameters to filter results
- ✓ Details of your videos
- Meta information (read / write)
- Video name (read / write)
- Require signed URLs (read-only)
- Width and height (read-only)
- ✓ Get embed code of your videos
- With or without signed URLs
- Add attributes to embed code
- controls
- ✓ Get playback URLs of your videos
- With or without signed token
- ✓ Generate signed tokens for your videos
- ✓ Delete your videos
Feel free to check out the Cloudflare Stream documentation and API documentation for further information.
Add the following to your root composer.json and install with composer install or composer update.
{
"require": {
"afloeter/laravel-cloudflare-stream": "~1.0.0"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/afloeter/laravel-cloudflare-stream"
}
]
...or use composer require afloeter/laravel-cloudflare-stream in your console after just adding the repository to your composer.json file.
Publish the config file with php artisan vendor:publish --provider="AFloeter\CloudflareStreamServiceProvider".
Add the following lines to your root .env file of your Laravel instance.
CLOUDFLARE_STREAM_ACCOUNT_ID=
CLOUDFLARE_STREAM_AUTH_KEY=
CLOUDFLARE_STREAM_AUTH_EMAIL=
CLOUDFLARE_STREAM_PRIVATE_KEY_ID=
CLOUDFLARE_STREAM_PRIVATE_KEY_TOKEN=
Complete the following information.
CLOUDFLARE_STREAM_ACCOUNT_IDis your Cloudflare account ID.CLOUDFLARE_STREAM_AUTH_KEYis your Cloudflare API key.CLOUDFLARE_STREAM_AUTH_EMAILis the email address of your Cloudflare account.
Leave CLOUDFLARE_STREAM_PRIVATE_KEY_ID and CLOUDFLARE_STREAM_PRIVATE_KEY_TOKEN blank if you don't use signed URLs at all.
CLOUDFLARE_STREAM_PRIVATE_KEY_IDis the ID of your signing keyCLOUDFLARE_STREAM_PRIVATE_KEY_TOKENis the related RSA private key.
Otherwise: Check the documentation on how to create a signing key and get RSA private key in PEM format.
If you have done the vendor:publish step, your credentials will be grabbed from the config/cloudflare-stream.php and / or .env file. So, you can use CloudflareStreamLaravel() without providing your information once again.
use AFloeter\CloudflareStream\CloudflareStreamLaravel;
...
$cfs = new CloudflareStreamLaravel();
$listOfVideos = $cfs->list();
...
If you are on composer-enabled projects use CloudflareStream(). Without composer try requiring src/CloudflareStream.php directly into your project.
use AFloeter\CloudflareStream\CloudflareStream;
...
$cfs = new CloudflareStream($accountId, $authKey, $authEMail);
$listOfVideos = $cfs->list();
...
If you are using signed URLs for your videos, simply add the $privateKey and $privateKeyToken variables.
use AFloeter\CloudflareStream\CloudflareStream;
...
$cfs = new CloudflareStream($accountId, $authKey, $authEMail, $privateKey, $privateKeyToken);
$signedToken = $cfs->getSignedToken($videoId);
...
It's planned to add support to...
- Upload a video
- From a URL
- Using a single HTTP request
- Using
ankitpokhrel/tus-php
- User uploads
- Create a video and get authenticated direct upload URL
- Create and revoke signing keys.
- Add, get and remove
.vttcaption files. - Set, get and remove allowed origins
All notable changes to laravel-cloudflare-stream will be documented here.
- initial release
laravel-cloudflare-stream is distributed under the terms of the MIT License.