Skip to content

Commit 40747df

Browse files
committed
initial commit
0 parents  commit 40747df

File tree

8 files changed

+610
-0
lines changed

8 files changed

+610
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
vendor
3+
composer.lock
4+
.idea

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright 2023 Bolaji Ajani [[email protected]](mailto:[email protected])
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Laravel Cloudflare Stream
2+
3+
A Laravel Package for working with Cloudflare Stream seamlessly
4+
5+
## Installation
6+
7+
Run
8+
```bash
9+
composer require bjthecod3r/laravel-cloudflare-stream
10+
```
11+
12+
## Configuration
13+
14+
You may publish the configuration file using this command:
15+
16+
```bash
17+
php artisan vendor:publish --provider="Bjthecod3r\CloudflareStream\CloudflareStreamServiceProvider"
18+
```
19+
20+
A configuration file named `cloudflare-stream` with some defaults and required properties will be placed in your `config` directory.
21+
22+
23+
## Usage
24+
25+
Open your .env file and add the following variables, remember to substitute the actual values
26+
27+
```php
28+
CLOUDFLARE_API_TOKEN=xxxxxxxxxxxx
29+
CLOUDFLARE_ACCOUNT_ID=xxxxxxxxxxxxxxxxx
30+
CLOUDFLARE_BASE_API_URL=https://api.cloudflare.com/client/v4/accounts
31+
CLOUDFLARE_KEY_ID=xxxxxxxxxxxxxxx
32+
```
33+
34+
Using the package is pretty straight forward, you can make use of the class like you would do any in Laravel. There is also support for facade.
35+
36+
```php
37+
use Bjthecod3r\CloudflareStream\CloudflareStream;
38+
39+
use Bjthecod3r\CloudflareStream\Facades\CloudflareStream as CloudflareStreamFacade;
40+
41+
class StreamService
42+
{
43+
public function fetchStream(string $id, CloudflareStream $cloudflareStream)
44+
{
45+
dd($cloudflareStream->fetchVideo($id));
46+
}
47+
48+
public function fetchVideo(string $id): array
49+
{
50+
return CloudflareStreamFacade::fetchVideo(string $id)
51+
}
52+
}
53+
```
54+
55+
## Note
56+
This package currently covers my current usage of cloudflare stream, although, in the next couple of weeks I plan to expand its features.
57+
However, if there is a need for a particular feature, feel free to reach out to me via [[email protected]](mailto:[email protected]), and I'll
58+
gladly attend to it.
59+
60+
## Todo
61+
62+
* Add Tests
63+
* Add the remaining useful features available on Cloudflare Stream
64+
65+
## Contributing
66+
67+
Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
68+
69+
70+
## License
71+
72+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

composer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "bjthecod3r/laravel-cloudflare-stream",
3+
"description": "A Laravel package for Cloudflare Stream.",
4+
"keywords": [
5+
"php",
6+
"laravel",
7+
"Open Source",
8+
"stream",
9+
"videos",
10+
"Laravel 10"
11+
],
12+
"license": "MIT",
13+
"minimum-stability": "dev",
14+
"autoload": {
15+
"psr-4": {
16+
"Bjthecod3r\\CloudflareStream\\": "src/"
17+
}
18+
},
19+
"authors": [
20+
{
21+
"name": "Bolaji Ajani",
22+
"email": "[email protected]"
23+
}
24+
],
25+
"require": {
26+
"php": "^8.1",
27+
"illuminate/support": "^10.0.0"
28+
},
29+
"extra": {
30+
"laravel": {
31+
"providers": [
32+
"CloudflareStreamServiceProvider"
33+
],
34+
"aliases": {
35+
"CloudflareStream": "Bjthecod3r\\CloudflareStream\\Facades\\CloudflareStream"
36+
}
37+
}
38+
}
39+
}

config/cloudflare-stream.php

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
return [
2+
3+
/*
4+
|--------------------------------------------------------------------------
5+
| API Token
6+
|--------------------------------------------------------------------------
7+
| This is the cloudflare API token for authentication of API requests
8+
|
9+
*/
10+
'api_token' => env('CLOUDFLARE_API_TOKEN', 'null'),
11+
12+
/*
13+
|--------------------------------------------------------------------------
14+
| Account ID
15+
|--------------------------------------------------------------------------
16+
| This is the cloudflare Account ID
17+
|
18+
*/
19+
'account_id' => env('CLOUDFLARE_ACCOUNT_ID', 'null'),
20+
21+
/*
22+
|--------------------------------------------------------------------------
23+
| Webhook Secret
24+
|--------------------------------------------------------------------------
25+
| This is the webhook secret
26+
|
27+
*/
28+
'webhook_secret' => env('CLOUDFLARE_WEBHOOK_SECRET', 'null'),
29+
30+
/*
31+
|--------------------------------------------------------------------------
32+
| Key ID
33+
|--------------------------------------------------------------------------
34+
| This is the jwk Key ID
35+
|
36+
*/
37+
'key_id' => env('CLOUDFLARE_KEY_ID', 'null'),
38+
39+
40+
/*
41+
|--------------------------------------------------------------------------
42+
| jwk Key
43+
|--------------------------------------------------------------------------
44+
| This is the jwk Key
45+
|
46+
*/
47+
'jwk_key' => env('CLOUDFLARE_JWK_KEY', 'null'),
48+
49+
/*
50+
|--------------------------------------------------------------------------
51+
| pem
52+
|--------------------------------------------------------------------------
53+
| This is the pem string generated
54+
|
55+
*/
56+
'pem' => env('CLOUDFLARE_PEM', 'null'),
57+
58+
/*
59+
|--------------------------------------------------------------------------
60+
| Base URL
61+
|--------------------------------------------------------------------------
62+
| This is the cloudflare API Base URL
63+
|
64+
*/
65+
'base_url' => env('CLOUDFLARE_API_BASE_URL', 'https://api.cloudflare.com/client/v4/accounts'),
66+
67+
/*
68+
|--------------------------------------------------------------------------
69+
| Default Options
70+
|--------------------------------------------------------------------------
71+
| This is the default options that will be applied to all upload
72+
| The `thumbnailTimestampPct` is a floating point value between 0.0 and 1.0.
73+
| All the commented defaults here don't seem to work for uploading via link
74+
|
75+
*/
76+
'default_options' => [
77+
'requireSignedURLs' => true,
78+
//'allowedOrigins' => [],
79+
//'thumbnailTimestampPct' => 0.0
80+
]
81+
];

0 commit comments

Comments
 (0)