muxinc / mux-php
Mux is how developers build online video. This API encompasses both Mux Video and Mux Data functionality to help you build your video-related projects better and faster than ever before.
Installs: 1 376 982
Dependents: 6
Suggesters: 0
Security: 0
Stars: 43
Watchers: 39
Forks: 30
Open Issues: 15
Requires
- php: >=7.4.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.4.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.14
- phpunit/phpunit: ^8.0 || ^9.0
- dev-master
- 3.21.0
- 3.20.0.x-dev
- 3.20.0
- 3.19.0
- 3.18.0
- 3.17.0
- 3.16.0
- 3.15.0
- 3.14.0
- 3.13.0
- 3.12.1
- 3.12.0
- 3.11.0
- 3.10.0
- 3.9.0
- 3.8.0
- 3.7.0
- 3.6.0
- 3.5.2
- 3.5.1
- 3.5.0
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.0
- 1.0.0-rc.1
- 0.9.0
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
- 0.0.4
- 0.0.3
- 0.0.2
- dev-js/v3.21.0
- dev-pc/3.16.0
- dev-ad/export-example
- dev-jsmith/generator-6.0.0-trial
- dev-jsmith/fix-php-deprecation-warnings
- dev-dk/return-types
- dev-dk/webhook-utils
- dev-ed/oas-pr-143-tests
- dev-ed/ll
- dev-ed/pre-1.0-updates
- dev-aa/fix-typo
- dev-ed/m1-fixes-for-builds
- dev-dependabot/npm_and_yarn/gen/hosted-git-info-2.8.9
- dev-ed/sdk-ng-build
- dev-ed/sdk-ng
- dev-ed/clipping
- dev-ed/get-asset-or-livestream-id
- dev-integration-test-in-release
- dev-guzzle-upgrade
- dev-incidents
This package is auto-updated.
Last update: 2024-11-20 22:52:09 UTC
README
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:
-
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. -
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.
Usage With Webhooks
At this moment, this SDK is not suitable for parsing or modeling webhook payloads, due to some incompatibilities in our API spec and our SDK generation tooling. We are working on resolving these issues, but for now you should only use this SDK for Mux's REST APIs.
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
Models
- AbridgedVideoView
- Asset
- AssetErrors
- AssetGeneratedSubtitleSettings
- AssetMaster
- AssetNonStandardInputReasons
- AssetRecordingTimes
- AssetResponse
- AssetStaticRenditions
- AssetStaticRenditionsFiles
- BreakdownValue
- Broadcast
- BroadcastLayout
- BroadcastResolution
- BroadcastResponse
- BroadcastStatus
- CreateAssetRequest
- CreateBroadcastRequest
- CreateLiveStreamRequest
- CreatePlaybackIDRequest
- CreatePlaybackIDResponse
- CreatePlaybackRestrictionRequest
- CreateSimulcastTargetRequest
- CreateSpaceRequest
- CreateTrackRequest
- CreateTrackResponse
- CreateTranscriptionVocabularyRequest
- CreateUploadRequest
- CreateWebInputRequest
- DRMConfiguration
- DRMConfigurationResponse
- DeliveryReport
- DeliveryReportDeliveredSecondsByResolution
- DimensionValue
- DisableLiveStreamResponse
- EnableLiveStreamResponse
- Error
- ExportDate
- ExportFile
- FilterValue
- GenerateTrackSubtitlesRequest
- GenerateTrackSubtitlesResponse
- GetAssetInputInfoResponse
- GetAssetOrLiveStreamIdResponse
- GetAssetOrLiveStreamIdResponseData
- GetAssetOrLiveStreamIdResponseDataObject
- GetAssetPlaybackIDResponse
- GetLiveStreamPlaybackIDResponse
- GetMetricTimeseriesDataResponse
- GetMonitoringBreakdownResponse
- GetMonitoringBreakdownTimeseriesResponse
- GetMonitoringHistogramTimeseriesResponse
- GetMonitoringHistogramTimeseriesResponseMeta
- GetMonitoringTimeseriesResponse
- GetOverallValuesResponse
- GetRealTimeBreakdownResponse
- GetRealTimeHistogramTimeseriesResponse
- GetRealTimeHistogramTimeseriesResponseMeta
- GetRealTimeTimeseriesResponse
- Incident
- IncidentBreakdown
- IncidentNotification
- IncidentNotificationRule
- IncidentResponse
- InputFile
- InputInfo
- InputSettings
- InputSettingsOverlaySettings
- InputTrack
- Insight
- LaunchWebInputResponse
- ListAllMetricValuesResponse
- ListAssetsResponse
- ListBreakdownValuesResponse
- ListBreakdownValuesResponseMeta
- ListDRMConfigurationsResponse
- ListDeliveryUsageResponse
- ListDimensionValuesResponse
- ListDimensionsResponse
- ListErrorsResponse
- ListExportsResponse
- ListFilterValuesResponse
- ListFiltersResponse
- ListFiltersResponseData
- ListIncidentsResponse
- ListInsightsResponse
- ListLiveStreamsResponse
- ListMonitoringDimensionsResponse
- ListMonitoringDimensionsResponseData
- ListMonitoringMetricsResponse
- ListPlaybackRestrictionsResponse
- ListRealTimeDimensionsResponse
- ListRealTimeMetricsResponse
- ListRelatedIncidentsResponse
- ListSigningKeysResponse
- ListSpacesResponse
- ListTranscriptionVocabulariesResponse
- ListUploadsResponse
- ListVideoViewExportsResponse
- ListVideoViewsResponse
- ListWebInputsResponse
- LiveStream
- LiveStreamEmbeddedSubtitleSettings
- LiveStreamGeneratedSubtitleSettings
- LiveStreamResponse
- LiveStreamStatus
- Metric
- MonitoringBreakdownTimeseriesDatapoint
- MonitoringBreakdownTimeseriesValues
- MonitoringBreakdownValue
- MonitoringHistogramTimeseriesBucket
- MonitoringHistogramTimeseriesBucketValues
- MonitoringHistogramTimeseriesDatapoint
- MonitoringTimeseriesDatapoint
- NotificationRule
- OverallValues
- PlaybackID
- PlaybackPolicy
- PlaybackRestriction
- PlaybackRestrictionResponse
- RealTimeBreakdownValue
- RealTimeHistogramTimeseriesBucket
- RealTimeHistogramTimeseriesBucketValues
- RealTimeHistogramTimeseriesDatapoint
- RealTimeTimeseriesDatapoint
- ReferrerDomainRestriction
- ReloadWebInputResponse
- Score
- ShutdownWebInputResponse
- SignalLiveStreamCompleteResponse
- SigningKey
- SigningKeyResponse
- SimulcastTarget
- SimulcastTargetResponse
- Space
- SpaceResponse
- SpaceStatus
- SpaceType
- StartSpaceBroadcastResponse
- StopSpaceBroadcastResponse
- Track
- TranscriptionVocabulary
- TranscriptionVocabularyResponse
- UpdateAssetMP4SupportRequest
- UpdateAssetMasterAccessRequest
- UpdateAssetRequest
- UpdateLiveStreamEmbeddedSubtitlesRequest
- UpdateLiveStreamGeneratedSubtitlesRequest
- UpdateLiveStreamNewAssetSettings
- UpdateLiveStreamRequest
- UpdateReferrerDomainRestrictionRequest
- UpdateTranscriptionVocabularyRequest
- UpdateUserAgentRestrictionRequest
- UpdateWebInputUrlRequest
- Upload
- UploadError
- UploadResponse
- UserAgentRestrictionRequest
- UserAgentRestrictionSettings
- VideoView
- VideoViewEvent
- VideoViewResponse
- WebInput
- WebInputResponse
Authorization
accessToken
- Type: HTTP basic authentication
Tests
To run the tests, use:
composer install vendor/bin/phpunit
Author
About this package
This PHP package is automatically generated by the OpenAPI Generator project:
- API version:
v1
- Package version:
3.21.0
- Package version:
- Build package:
org.openapitools.codegen.languages.PhpClientCodegen