Giter Club home page Giter Club logo

mux-php's Introduction

Mux PHP Banner

Packagist | Mux Docs | Mux API Reference

Mux PHP

Official Mux API wrapper for PHP projects, supporting both Mux Data and Mux Video.

Mux Video is an API-first platform, powered by data and designed by video experts to make beautiful video possible for every development team.

Mux Data is a platform for monitoring your video streaming performance with just a few lines of code. Get in-depth quality of service analytics on web, mobile, and OTT devices.

Not familiar with Mux? Check out https://mux.com/ for more information.

Requirements

PHP 7.1 or higher. Dependencies are managed using composer.

Installation

We publish Mux PHP to Packagist. You should depend on Mux PHP by adding us to your composer.json:

    {
        "require": {
            "muxinc/mux-php": ">=0.0.1"
        }
    }

Then install your dependencies:

    composer install

And then autoload in your code:

    require_once 'vendor/autoload.php';

Manual Installation

PLEASE NOTE: We don't really recommend manual installation and our ability to help if this route doesn't work is minimal. We include this mostly for purposes of completeness.

Download the files and include autoload.php:

<?php
require_once('/path/to/MuxPhp/vendor/autoload.php');

Getting Started

Overview

Mux PHP is a code generated lightweight wrapper around the Mux REST API and reflects them accurately. This has a few consequences you should watch out for:

  1. For almost all API responses, the object you're looking for will be in the data field on the API response object, as in the example below. This is because we designed our APIs with similar concepts to the JSON:API standard. This means we'll be able to return more metadata from our API calls (such as related entities) without the need to make breaking changes to our APIs. We've decided not to hide that in this library.

  2. We don't use a lot of object orientation. For example API calls that happen on a single asset don't exist in the asset class, but are API calls in the AssetsApi which require an asset ID.

Authentication

To use the Mux API, you'll need an access token and a secret. Details on obtaining these can be found here in the Mux documentation.

Its up to you to manage your token and secret. In our examples, we read them from MUX_TOKEN_ID and MUX_TOKEN_SECRET in your environment.

Example Usage

Below is a quick example of using mux-php to ingest a new Video in your Mux account.

    // Authentication Setup
    $config = MuxPhp\Configuration::getDefaultConfiguration()
        ->setUsername(getenv('MUX_TOKEN_ID'))
        ->setPassword(getenv('MUX_TOKEN_SECRET'));

    // API Client Initialization
    $assetsApi = new MuxPhp\Api\AssetsApi(
        new GuzzleHttp\Client(),
        $config
    );

    // Create Asset Request
    $input = new MuxPhp\Models\InputSettings(["url" => "https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4"]);
    $createAssetRequest = new MuxPhp\Models\CreateAssetRequest(["input" => $input, "playback_policy" => [MuxPhp\Models\PlaybackPolicy::PUBLIC_PLAYBACK_POLICY] ]);

    // Ingest
    $result = $assetsApi->createAsset($createAssetRequest);

    // Print URL
    print "Playback URL: https://stream.mux.com/" . $result->getData()->getPlaybackIds()[0]->getId() . ".m3u8\n"

Be sure to also checkout the examples directory:

There's also example usage of every API call (also used for testing):

Documentation

Be sure to check out the documentation in the docs directory.

Issues

If you run into problems, please raise a GitHub issue. We'll take a look as soon as possible.

Contributing

We now accept PRs against this package! Please make your modifications to the templates in gen/templates, not the code itself, or please open an issue.

License

MIT License. Copyright 2019 Mux, Inc.

API Endpoints

All URIs are relative to https://api.mux.com

Class Method HTTP request Description
AssetsApi createAsset POST /video/v1/assets Create an asset
AssetsApi createAssetPlaybackId POST /video/v1/assets/{ASSET_ID}/playback-ids Create a playback ID
AssetsApi createAssetTrack POST /video/v1/assets/{ASSET_ID}/tracks Create an asset track
AssetsApi deleteAsset DELETE /video/v1/assets/{ASSET_ID} Delete an asset
AssetsApi deleteAssetPlaybackId DELETE /video/v1/assets/{ASSET_ID}/playback-ids/{PLAYBACK_ID} Delete a playback ID
AssetsApi deleteAssetTrack DELETE /video/v1/assets/{ASSET_ID}/tracks/{TRACK_ID} Delete an asset track
AssetsApi getAsset GET /video/v1/assets/{ASSET_ID} Retrieve an asset
AssetsApi getAssetInputInfo GET /video/v1/assets/{ASSET_ID}/input-info Retrieve asset input info
AssetsApi getAssetPlaybackId GET /video/v1/assets/{ASSET_ID}/playback-ids/{PLAYBACK_ID} Retrieve a playback ID
AssetsApi listAssets GET /video/v1/assets List assets
AssetsApi updateAsset PATCH /video/v1/assets/{ASSET_ID} Update an Asset
AssetsApi updateAssetMasterAccess PUT /video/v1/assets/{ASSET_ID}/master-access Update master access
AssetsApi updateAssetMp4Support PUT /video/v1/assets/{ASSET_ID}/mp4-support Update MP4 support
DeliveryUsageApi listDeliveryUsage GET /video/v1/delivery-usage List Usage
DimensionsApi listDimensionValues GET /data/v1/dimensions/{DIMENSION_ID} Lists the values for a specific dimension
DimensionsApi listDimensions GET /data/v1/dimensions List Dimensions
DirectUploadsApi cancelDirectUpload PUT /video/v1/uploads/{UPLOAD_ID}/cancel Cancel a direct upload
DirectUploadsApi createDirectUpload POST /video/v1/uploads Create a new direct upload URL
DirectUploadsApi getDirectUpload GET /video/v1/uploads/{UPLOAD_ID} Retrieve a single direct upload's info
DirectUploadsApi listDirectUploads GET /video/v1/uploads List direct uploads
ErrorsApi listErrors GET /data/v1/errors List Errors
ExportsApi listExports GET /data/v1/exports List property video view export links
ExportsApi listExportsViews GET /data/v1/exports/views List available property view exports
FiltersApi listFilterValues GET /data/v1/filters/{FILTER_ID} Lists values for a specific filter
FiltersApi listFilters GET /data/v1/filters List Filters
IncidentsApi getIncident GET /data/v1/incidents/{INCIDENT_ID} Get an Incident
IncidentsApi listIncidents GET /data/v1/incidents List Incidents
IncidentsApi listRelatedIncidents GET /data/v1/incidents/{INCIDENT_ID}/related List Related Incidents
LiveStreamsApi createLiveStream POST /video/v1/live-streams Create a live stream
LiveStreamsApi createLiveStreamPlaybackId POST /video/v1/live-streams/{LIVE_STREAM_ID}/playback-ids Create a live stream playback ID
LiveStreamsApi createLiveStreamSimulcastTarget POST /video/v1/live-streams/{LIVE_STREAM_ID}/simulcast-targets Create a live stream simulcast target
LiveStreamsApi deleteLiveStream DELETE /video/v1/live-streams/{LIVE_STREAM_ID} Delete a live stream
LiveStreamsApi deleteLiveStreamPlaybackId DELETE /video/v1/live-streams/{LIVE_STREAM_ID}/playback-ids/{PLAYBACK_ID} Delete a live stream playback ID
LiveStreamsApi deleteLiveStreamSimulcastTarget DELETE /video/v1/live-streams/{LIVE_STREAM_ID}/simulcast-targets/{SIMULCAST_TARGET_ID} Delete a Live Stream Simulcast Target
LiveStreamsApi disableLiveStream PUT /video/v1/live-streams/{LIVE_STREAM_ID}/disable Disable a live stream
LiveStreamsApi enableLiveStream PUT /video/v1/live-streams/{LIVE_STREAM_ID}/enable Enable a live stream
LiveStreamsApi getLiveStream GET /video/v1/live-streams/{LIVE_STREAM_ID} Retrieve a live stream
LiveStreamsApi getLiveStreamPlaybackId GET /video/v1/live-streams/{LIVE_STREAM_ID}/playback-ids/{PLAYBACK_ID} Retrieve a live stream playback ID
LiveStreamsApi getLiveStreamSimulcastTarget GET /video/v1/live-streams/{LIVE_STREAM_ID}/simulcast-targets/{SIMULCAST_TARGET_ID} Retrieve a Live Stream Simulcast Target
LiveStreamsApi listLiveStreams GET /video/v1/live-streams List live streams
LiveStreamsApi resetStreamKey POST /video/v1/live-streams/{LIVE_STREAM_ID}/reset-stream-key Reset a live stream's stream key
LiveStreamsApi signalLiveStreamComplete PUT /video/v1/live-streams/{LIVE_STREAM_ID}/complete Signal a live stream is finished
LiveStreamsApi updateLiveStream PATCH /video/v1/live-streams/{LIVE_STREAM_ID} Update a live stream
LiveStreamsApi updateLiveStreamEmbeddedSubtitles PUT /video/v1/live-streams/{LIVE_STREAM_ID}/embedded-subtitles Update a live stream's embedded subtitles
LiveStreamsApi updateLiveStreamGeneratedSubtitles PUT /video/v1/live-streams/{LIVE_STREAM_ID}/generated-subtitles Update a live stream's generated subtitles
MetricsApi getMetricTimeseriesData GET /data/v1/metrics/{METRIC_ID}/timeseries Get metric timeseries data
MetricsApi getOverallValues GET /data/v1/metrics/{METRIC_ID}/overall Get Overall values
MetricsApi listAllMetricValues GET /data/v1/metrics/comparison List all metric values
MetricsApi listBreakdownValues GET /data/v1/metrics/{METRIC_ID}/breakdown List breakdown values
MetricsApi listInsights GET /data/v1/metrics/{METRIC_ID}/insights List Insights
PlaybackIDApi getAssetOrLivestreamId GET /video/v1/playback-ids/{PLAYBACK_ID} Retrieve an Asset or Live Stream ID
PlaybackRestrictionsApi createPlaybackRestriction POST /video/v1/playback-restrictions Create a Playback Restriction
PlaybackRestrictionsApi deletePlaybackRestriction DELETE /video/v1/playback-restrictions/{PLAYBACK_RESTRICTION_ID} Delete a Playback Restriction
PlaybackRestrictionsApi getPlaybackRestriction GET /video/v1/playback-restrictions/{PLAYBACK_RESTRICTION_ID} Retrieve a Playback Restriction
PlaybackRestrictionsApi listPlaybackRestrictions GET /video/v1/playback-restrictions List Playback Restrictions
PlaybackRestrictionsApi updateReferrerDomainRestriction PUT /video/v1/playback-restrictions/{PLAYBACK_RESTRICTION_ID}/referrer Update the Referrer Playback Restriction
RealTimeApi getRealtimeBreakdown GET /data/v1/realtime/metrics/{REALTIME_METRIC_ID}/breakdown Get Real-Time Breakdown
RealTimeApi getRealtimeHistogramTimeseries GET /data/v1/realtime/metrics/{REALTIME_HISTOGRAM_METRIC_ID}/histogram-timeseries Get Real-Time Histogram Timeseries
RealTimeApi getRealtimeTimeseries GET /data/v1/realtime/metrics/{REALTIME_METRIC_ID}/timeseries Get Real-Time Timeseries
RealTimeApi listRealtimeDimensions GET /data/v1/realtime/dimensions List Real-Time Dimensions
RealTimeApi listRealtimeMetrics GET /data/v1/realtime/metrics List Real-Time Metrics
SpacesApi createSpace POST /video/v1/spaces Create a space
SpacesApi createSpaceBroadcast POST /video/v1/spaces/{SPACE_ID}/broadcasts Create a space broadcast
SpacesApi deleteSpace DELETE /video/v1/spaces/{SPACE_ID} Delete a space
SpacesApi deleteSpaceBroadcast DELETE /video/v1/spaces/{SPACE_ID}/broadcasts/{BROADCAST_ID} Delete a space broadcast
SpacesApi getSpace GET /video/v1/spaces/{SPACE_ID} Retrieve a space
SpacesApi getSpaceBroadcast GET /video/v1/spaces/{SPACE_ID}/broadcasts/{BROADCAST_ID} Retrieve space broadcast
SpacesApi listSpaces GET /video/v1/spaces List spaces
SpacesApi startSpaceBroadcast POST /video/v1/spaces/{SPACE_ID}/broadcasts/{BROADCAST_ID}/start Start a space broadcast
SpacesApi stopSpaceBroadcast POST /video/v1/spaces/{SPACE_ID}/broadcasts/{BROADCAST_ID}/stop Stop a space broadcast
TranscriptionVocabulariesApi createTranscriptionVocabulary POST /video/v1/transcription-vocabularies Create a Transcription Vocabulary
TranscriptionVocabulariesApi deleteTranscriptionVocabulary DELETE /video/v1/transcription-vocabularies/{TRANSCRIPTION_VOCABULARY_ID} Delete a Transcription Vocabulary
TranscriptionVocabulariesApi getTranscriptionVocabulary GET /video/v1/transcription-vocabularies/{TRANSCRIPTION_VOCABULARY_ID} Retrieve a Transcription Vocabulary
TranscriptionVocabulariesApi listTranscriptionVocabularies GET /video/v1/transcription-vocabularies List Transcription Vocabularies
TranscriptionVocabulariesApi updateTranscriptionVocabulary PUT /video/v1/transcription-vocabularies/{TRANSCRIPTION_VOCABULARY_ID} Update a Transcription Vocabulary
URLSigningKeysApi createUrlSigningKey POST /video/v1/signing-keys Create a URL signing key
URLSigningKeysApi deleteUrlSigningKey DELETE /video/v1/signing-keys/{SIGNING_KEY_ID} Delete a URL signing key
URLSigningKeysApi getUrlSigningKey GET /video/v1/signing-keys/{SIGNING_KEY_ID} Retrieve a URL signing key
URLSigningKeysApi listUrlSigningKeys GET /video/v1/signing-keys List URL signing keys
VideoViewsApi getVideoView GET /data/v1/video-views/{VIDEO_VIEW_ID} Get a Video View
VideoViewsApi listVideoViews GET /data/v1/video-views List Video Views

Models

Authorization

accessToken

  • Type: HTTP basic authentication

Tests

To run the tests, use:

composer install
vendor/bin/phpunit

Author

[email protected]

About this package

This PHP package is automatically generated by the OpenAPI Generator project:

  • API version: v1
    • Package version: 3.6.0
  • Build package: org.openapitools.codegen.languages.PhpClientCodegen

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.