joggapp/laravel-mux

Laravel package for Mux API

Maintainers

Package info

github.com/JoggApp/laravel-mux

pkg:composer/joggapp/laravel-mux

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v5.10 2025-03-19 19:40 UTC

This package is auto-updated.

Last update: 2026-05-19 13:26:15 UTC


README

Latest Version Total Downloads

This package makes using Mux' API with a laravel app easy and simple.

Installation

  • You can install this package via composer using this command:
composer require joggapp/laravel-mux
  • The package will automatically register itself.

  • You can publish the config file, database tables, webhook route using the following command:

php artisan vendor:publish --provider="JoggApp\Mux\MuxServiceProvider"

This will create the package's config file called laravel-mux.php in the config directory. These are the contents of the published config file:

return [
    'access_token' => env('MUX_ACCESS_TOKEN'),

    'secret_key' => env('MUX_SECRET_KEY'),

    'api_url' => env('MUX_API_URL', 'https://api.mux.com/video/v1'),

    'webhook_processing_queue' => env('MUX_WEBHOOK_PROCESSING_QUEUE', 'encoding'),

    'webhook_secret' => env('MUX_WEBHOOK_SECRET')
];

How to use

  • Setup config

    • webhook_secret can be found in Mux dashboard under Settings > Webhooks:
    205170051-1fa985bb-5c02-4b05-9a09-0a55755a0048
  • Run migrations

  • You then need to pass the route to muxWebhook in your routes file:

Route::muxWebhook('route-you-prefer')->middleware('validate.mux.signature');
  • You need to implement the JoggApp\Mux\Contracts\Media interface on the model you want to use as the one to be operated on. Eg: App\Models\Video. You will also need to implement the methods that interface asks for in your model.

  • The command JoggApp\Mux\Commands\KeepCheckingForLaravelMuxErrors is scheduled to run every minute via this packages service-provider. Make sure you have run the migrations. You can set the threshold count in the config file, if which is crossed in the last hour the pkg will emit an event MuxErrorsThresholdCrossed that you can hook into and do anything you like, for eg notify on slack, swap services etc. The count has been set to a sensible default of 3 per hour.

  • The available methods are:

Mux::encode(Media $media, array $options = []): Response
Mux::addCaptionsToVideo(Media $media, array $options = []): Response
Mux::getAssetDetails(string $assetId): Response
  • There is a ValidateMuxSignature middleware available which when applied to the mux webhook route, will take care of the webhook secret verification.

  • This package emits the following events:

  1. MuxAddingCaptionsToVideoFailed

  2. MuxAddingCaptionsToVideoSuccessful

  3. MuxMediaEncodingFailed

  4. MuxMediaEncodingSuccessful

  5. MuxVideoAssetFailedWebhookReceived

  6. MuxVideoAssetReadyWebhookReceived

  7. MuxVideoAssetStaticRenditionsReadyWebhookReceived

  8. MuxErrorsThresholdCrossed

Testing

You can run the tests with:

vendor/bin/phpunit

Changelog

Please see the CHANGELOG for more information about what has changed recently.

Security

If you discover any security related issues, please email them to harish@jogg.co instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see the License File for more information.