Skip to content
/ mux-php Public

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

License

Notifications You must be signed in to change notification settings

muxinc/mux-php

Repository files navigation

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.

Documentation note

Please note that our SDK and the API documentation are generated from our OpenAPI specification. Many of the examples in our specification have JSON strings representing the sample values. Because of this, many of the API documentation examples use the json_encode() function to convert that JSON string into a PHP associative array. In your own code, you can skip that step and use an associative array directly, or create a new object using the appropriate model as shown in the example below.

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] ]);

    // 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 generateAssetTrackSubtitles POST /video/v1/assets/{ASSET_ID}/tracks/{TRACK_ID}/generate-subtitles Generate track subtitles
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
DRMConfigurationsApi getDrmConfiguration GET /video/v1/drm-configurations/{DRM_CONFIGURATION_ID} Retrieve a DRM Configuration
DRMConfigurationsApi listDrmConfigurations GET /video/v1/drm-configurations List DRM Configurations
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
MonitoringApi getMonitoringBreakdown GET /data/v1/monitoring/metrics/{MONITORING_METRIC_ID}/breakdown Get Monitoring Breakdown
MonitoringApi getMonitoringBreakdownTimeseries GET /data/v1/monitoring/metrics/{MONITORING_METRIC_ID}/breakdown-timeseries Get Monitoring Breakdown Timeseries
MonitoringApi getMonitoringHistogramTimeseries GET /data/v1/monitoring/metrics/{MONITORING_HISTOGRAM_METRIC_ID}/histogram-timeseries Get Monitoring Histogram Timeseries
MonitoringApi getMonitoringTimeseries GET /data/v1/monitoring/metrics/{MONITORING_METRIC_ID}/timeseries Get Monitoring Timeseries
MonitoringApi listMonitoringDimensions GET /data/v1/monitoring/dimensions List Monitoring Dimensions
MonitoringApi listMonitoringMetrics GET /data/v1/monitoring/metrics List Monitoring Metrics
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
PlaybackRestrictionsApi updateUserAgentRestriction PUT /video/v1/playback-restrictions/{PLAYBACK_RESTRICTION_ID}/user_agent Update the User Agent 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
SigningKeysApi createSigningKey POST /system/v1/signing-keys Create a signing key
SigningKeysApi deleteSigningKey DELETE /system/v1/signing-keys/{SIGNING_KEY_ID} Delete a signing key
SigningKeysApi getSigningKey GET /system/v1/signing-keys/{SIGNING_KEY_ID} Retrieve a signing key
SigningKeysApi listSigningKeys GET /system/v1/signing-keys List signing keys
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
WebInputsApi createWebInput POST /video/v1/web-inputs Create a new Web Input
WebInputsApi deleteWebInput DELETE /video/v1/web-inputs/{WEB_INPUT_ID} Delete a Web Input
WebInputsApi getWebInput GET /video/v1/web-inputs/{WEB_INPUT_ID} Retrieve a Web Input
WebInputsApi launchWebInput PUT /video/v1/web-inputs/{WEB_INPUT_ID}/launch Launch a Web Input
WebInputsApi listWebInputs GET /video/v1/web-inputs List Web Inputs
WebInputsApi reloadWebInput PUT /video/v1/web-inputs/{WEB_INPUT_ID}/reload Reload a Web Input
WebInputsApi shutdownWebInput PUT /video/v1/web-inputs/{WEB_INPUT_ID}/shutdown Shut down a Web Input
WebInputsApi updateWebInputUrl PUT /video/v1/web-inputs/{WEB_INPUT_ID}/url Update Web Input URL

Models

Authorization

accessToken

  • Type: HTTP basic authentication

Tests

To run the tests, use:

composer install
vendor/bin/phpunit

Author

devex@mux.com

About this package

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

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