Giter Club home page Giter Club logo

php-cfstream's Introduction

PHP - Cloudflare Stream

PHP CFStream is a PHP TUS client that makes it easy to send video files to Cloudflare Stream.

  • Simple interface that supports:
    • Upload videos
    • Get status of uploaded videos
    • Get embed code for videos
    • Set allowedOrigins for each video
    • Delete videos
  • Implemented in pure PHP and CURL with the help of GuzzleHttp Client
  • Tightly integrated with Cloudflare Stream
  • Does not support:
    • Resume uploads

Installation

Install the package via Composer as usual. Use the dev-master branch.

composer require jianjye/php-cfstream dev-master

Laravel 5.0+

For Laravel 5.0 and newer projects, you can do vendor:publish to enable basic integrations:

php artisan vendor:publish 

Then select Provider: JianJye\CFStream\Laravel\ServiceProvider. cfstream.php will be copied to your config folder.

After that, add these into your .env file:

CLOUDFLARE_KEY=
CLOUDFLARE_ZONE=
CLOUDFLARE_EMAIL=

Usage

Generic PHP Projects

If you are on composer-enabled projects, the following instructions should work for you. Otherwise try requiring src/CFStream.php directly in your project instead.

use JianJye\CFStream\CFStream;

$cfstream = new CFStream($key, $zone, $email);

$resourceUrl = $cfstream->upload($filepath);
$cfstream->status($resourceUrl);
$cfstream->code($resourceUrl);
$cfstream->allow($resourceUrl, 'example.com, *.example.net');
$cfstream->delete($resourceUrl);

Laravel Projects

If you have done the vendor:publish step, then CFStream can grab your credentials from the config file. You can use the CFStreamLaravel client instead.

use JianJye\CFStream\CFStreamLaravel;

$cfstream = new CFStreamLaravel();

$resourceUrl = $cfstream->upload($filepath);
$cfstream->status($resourceUrl);
$cfstream->code($resourceUrl);
$cfstream->allow($resourceUrl, 'example.com, *.example.net');
$cfstream->delete($resourceUrl);

Changelog

2019-04-02 - Namespace Changed

The namespace of this project has been updated from JJSee to JianJye. Please update your projects accordingly.

php-cfstream's People

Contributors

jianjye avatar jjsee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.