1. Go to this page and download the library: Download martinbean/mux-php-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
martinbean / mux-php-laravel example snippets
namespace App\Http\Controllers;
use MuxPhp\Api\DirectUploadsApi;
class UploadController extends Controller
{
protected DirectUploadsApi $uploads;
public function __construct(DirectUploadsApi $uploads)
{
$this->uploads = $uploads;
}
}
namespace App\Listeners;
use MartinBean\Laravel\Mux\Events\WebhookReceived;
class MuxEventListener
{
public function handle(WebhookReceived $event): void
{
// Handle Mux webhook event...
}
}
diff
public function handle(WebhookReceived $event): void
{
- // Handle Mux webhook event...
+ match ($event->payload['type']) {
+ 'video.asset.errored' => $this->handleVideoAssetErrored($event->payload),
+ 'video.asset.ready' => $this->handleVideoAssetReady($event->payload),
+ default => null, // unhandled event
+ };
}
+
+ protected function handleVideoAssetErrored(array $payload): void
+ {
+ // TODO: Retrieve associated video
+ // TODO: Update video status to 'errored'
+ // TODO: Notify user processing video errored
+ }
+
+ protected function handleVideoAssetReady(array $payload): void
+ {
+ // TODO: Retrieve associated video
+ // TODO: Update video status to 'ready'
+ // TODO: Notify user processing video succeeded
+ }
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.