Before you go, check out these stories!

Hackernoon logoAdd video to your personal homepage with Mux PHP by@mux

Add video to your personal homepage with Mux PHP

Author profile picture


Like a lot of people discovering programming in the early 2000s, PHP was the first programming language I learned. Long before great online resources existed, I had this dusty old thing called a book, littered with mystical lines of PHP that I only partially understood.

While usage has been declining, PHP is still the 7th most used language on Github, and we’ve heard your cries loud and clear - you need a PHP SDK.

Well, good news! Last week, I dusted off my old PHP book and got to work! 🎉

Just kidding, we generated a shiny new PHP SDK, just for you, because we love you. 😘

Mux PHP is a lightweight wrapper around Mux’s APIs, which make it easy to integrate Mux-powered video experiences into your PHP apps.

It’s super easy to ingest some content into your Mux account using Mux PHP - let’s take a look at a simple app which does just that!

  require_once 'vendor/autoload.php';
  // Authentication Setup
  $config = MuxPhp\Configuration::getDefaultConfiguration()
  // API Client Initialization
  $assetsApi = new MuxPhp\Api\AssetsApi(
      new GuzzleHttp\Client(),
  // Create Asset Request
  $input = new MuxPhp\Models\InputSettings(["url" => ""]);
  $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:" . $result->getData()->getPlaybackIds()[0]->getId() . ".m3u8\n"

Mux PHP is, of course, the latest in the line of our SDKs generated from the OpenAPI definitions of our APIs. We wrote about how we’re building our code-generated SDKsand some of the challenges we’ve experienced on our blog. Check it out!

We’ll be releasing even more SDKs over the coming months, but if you have a burning desire for an SDK in a particular language, please get in touch so we work on what’s most important to you.

We’re really excited to see what you build using Mux PHP - show us your cool projects via Twitter at @MuxHQ.


Join Hacker Noon

Create your free account to unlock your custom reading experience.