PHP SDK

Build video on FastPix from PHP: a php video SDK

The official FastPix SDK for PHP. Typed end-to-end, async-aware, retry-safe. Encodes a source URL into a playback ID in one call, provisions LL-HLS live streams, verifies webhooks with one helper, and ships with a migration path from the closest API peer (see comparison).

PHP 8.1Min runtime
Typedend-to-end
Asyncthroughout

Trusted by product teams shipping video at scale

AAO NXTAadhanKnovorocketlaneDLICOMPractice by Numberssuperbit

Install

One install, one client, one call

Add the package, point the client at your API key, and you're talking to FastPix — strongly-typed, no scaffolding.

01

Install the package

bash · terminal

bash · terminal
composer require fastpix/fastpix-php

Runtime

PHP 8.1+, Laravel 10+ / Symfony 6.4+.

Type safety

PHP 8.1+ enums, readonly classes, typed properties everywhere.

IDE support

PhpStorm, VS Code with Intelephense, full type inference.

02

Initialize the client

PHP · app.php

PHP · app.php
use FastPix\Client;

$fp = new Client(apiKey: $_ENV['FASTPIX_API_KEY']);

Common operations

From upload to playback in 4 calls

Encode, wait, stream, upload. The four most common flows, typed end-to-end.

1. Encode a source URL into a playback ID

$fp->assets->create
$asset = $fp->assets->create(
    inputs: [['url' => 'https://your-cdn.com/source.mp4']],
    playbackPolicy: PlaybackPolicy::Public,
);

echo $asset->playbackId;  // "abc123"

2. Wait until the asset is ready

$fp->assets->waitUntilReady
// Poll until the asset is ready, or listen for the asset.ready webhook.
$ready = $fp->assets->waitUntilReady(
    $asset->id,
    pollIntervalSeconds: 2,
    timeoutSeconds: 300,
);

3. Provision a low-latency live stream

$fp->live->create
$stream = $fp->live->create(
    latencyMode: LatencyMode::Low,            //  LL-HLS
    reconnectWindowSeconds: 60,
    playbackPolicy: PlaybackPolicy::Public,
);
// $stream->streamKey -> push to rtmp://global-live.fastpix.com/live

4. Resumable chunked upload

FastPix\Upload
// Resumable chunked upload from a PHP CLI worker
use FastPix\Upload\ChunkedUpload;

ChunkedUpload::fromPath(
    endpoint:    $assetUploadUrl,
    path:        __DIR__ . '/source.mp4',
    chunkSizeMb: 8,
    onProgress:  fn(int $pct) => echo "{$pct}%\n",
)->run();

Security, compliance, and partnerships

PartnerNVIDIA Inception
PartnerGoogle Cloud Partner

Webhook signature verification

One helper, every event typed

Every webhook FastPix sends is signed. The SDK verifies the signature and returns a fully-typed event payload. Switch on event.type and reach the typed payload directly.

webhook.php
use FastPix\Webhooks;

// Laravel route example
Route::post('/webhooks/fastpix', function (Request $request) {
    $event = Webhooks::verify(
        payload:   $request->getContent(),
        signature: $request->header('FastPix-Signature'),
        secret:    env('FASTPIX_WEBHOOK_SECRET'),
    );

    match ($event->type) {
        'asset.ready' => /* $event->data is fully typed */ null,
        default       => null,
    };

    return response()->noContent();
});

Concurrency model

Built for the PHP runtime

Single-request-per-process by default (the PHP-FPM model). For Laravel Octane and Swoole, the Client can be safely shared as a long-lived singleton; per-request state is local to each request handler. PSR-18 HTTP client is pluggable.

Type safety + IDE support

PHP 8.1+ readonly classes and enums are used throughout. Webhook event payloads are tagged unions via the type property and a typed data property. PHPStan and Psalm level 8 clean out of the box.

Migration

Swap the client, keep the shape

FastPix exposes primitives that mirror the closest API peer. The PHP SDK keeps the call shapes recognizable so the migration is a one-file swap, not a rewrite. FastPix vs Mux side-by-side.

migrate.php
// Before: use MuxPhp\Api\AssetsApi;
// FastPix:
use FastPix\Client;

$fp = new Client(apiKey: $_ENV['FASTPIX_API_KEY']);

// Before: $result = $assetsApi->createAsset($createAssetRequest);
// FastPix:
$asset = $fp->assets->create(
    inputs: [['url' => $url]],
    playbackPolicy: PlaybackPolicy::Public,
);

// Before: $result->getData()->getPlaybackIds()[0]->getId();
// FastPix:
$asset->playbackId;

Bulk migration tooling at /compare/mux and the docs migration guide handles asset re-ingest and playback-ID remap.

FAQ

PHP SDK FAQ

  • What does the PHP SDK ship with out of the box?

    All API surfaces (assets, live streams, playback policies, webhooks, simulcast, analytics query) plus the resumable chunked upload helper, webhook signature verification, automatic retries with exponential backoff, and configurable timeout / base URL / HTTP client. Type definitions are bundled.
  • Is the PHP SDK production-ready?

    Yes. The client is used in production by FastPix customers shipping video on the PHP runtime. The retry policy, connection pool defaults, and timeout shape are tuned against the same workload patterns that produce the numbers on the /performance page.
  • How do I authenticate against the FastPix API from PHP?

    Set the FASTPIX_API_KEY environment variable and pass it to the client constructor. The SDK adds the Bearer header on every request. For server-side runtimes, fetching the API key from your secret store at startup and constructing the client once at module load is the recommended pattern.
  • Where do I get an API key?

    Sign up at the FastPix dashboard. The free trial provisions a key with no credit card; the trial plan covers 10 videos plus 100K streaming minutes plus AI samples. See /pricing for the full plan structure.

Read it, run it, ship it.

Every SDK, player, and integration lives on GitHub. Star the repos, file an issue, or open a PR — we build alongside the developers who use us.

Browse the repos