PHP SDK

Learn how the FastPix PHP SDK enables video uploads, live streaming, and playback management in PHP applications.

Add secure, scalable video to your PHP project

The FastPix PHP SDK gives you everything you need to manage video from your backend. Upload files from a public URL, attach metadata, and retrieve playback links, all without building encoding pipelines or managing storage. With this SDK, you can:

  • Upload and organize video assets
  • Define access control and metadata
  • Generate HLS playback URLs
  • Streamline video delivery from your PHP server

Find more in the SDK reference

To explore more examples, API methods, and advanced usage, see the FastPix PHP SDK on GitHub.


Prerequisites

Before you start using the SDK, make sure you have the following:

  • PHP 8.2 or later: This SDK is compatible with PHP 8.2 or higher
  • Composer: Required for dependency management
  • cURL extension: Required for HTTP requests
  • JSON extension: Required for JSON processing
  • FastPix API credentials: You’ll need an Access Token and a Secret Key. You can generate these credentials by following the steps in the authentication guide
  • Basic understanding of PHP and REST APIs: Familiarity with PHP development and API integration concepts

Installation

Install the SDK using Composer:

Add the SDK to your project:

1{
2 "require": {
3 "fastpix/sdk": "*"
4 }
5}

Then run:

$composer update

If you host the package in a private repository, add the repository to your composer.json:

1{
2 "repositories": [
3 {
4 "type": "vcs",
5 "url": "https://github.com/your-org/fastpix-sdk-php.git"
6 }
7 ],
8 "require": {
9 "fastpix/sdk": "*"
10 }
11}

Import the SDK

1<?php
2
3require 'vendor/autoload.php';
4
5use FastPix\Sdk;
6use FastPix\Sdk\Models\Components;
7use FastPix\Sdk\Models\Operations;

Example

Let’s create a file named index.php

This example shows how to upload a video from a public URL with metadata and public access:

NOTE:
In the following example, replace your-access-token and your-secret-key with the Access Token ID and Secret Key values from the .env file you downloaded.

1<?php
2
3declare(strict_types=1);
4
5require 'vendor/autoload.php';
6
7use FastPix\Sdk;
8use FastPix\Sdk\Models\Components;
9
10try {
11 $sdk = Sdk\Fastpixsdk::builder()
12 ->setSecurity(
13 new Components\Security(
14 username: 'your-access-token',
15 password: 'your-secret-key',
16 )
17 )
18 ->build();
19
20 $request = new Components\CreateMediaRequest(
21 inputs: [
22 new Components\PullVideoInput(),
23 ],
24 metadata: [
25 'key1' => 'value1',
26 ],
27 );
28
29 $response = $sdk->inputVideo->createMedia(
30 request: $request
31);
32
33 if ($response->statusCode >= 200 && $response->statusCode < 300) {
34 $rawBody = (string) $response->rawResponse->getBody();
35 $decoded = json_decode($rawBody, true);
36 echo ($decoded !== null ? json_encode($decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) : $rawBody) . "\n";
37 } else {
38 $errorPayload = $response->defaultError ?? $response->error ?? null;
39 if ($errorPayload !== null) {
40 $errorResponse = json_decode(json_encode($errorPayload), true);
41 echo json_encode($errorResponse, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
42 } else {
43 echo json_encode(['message' => 'No response data'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
44 }
45 }
46} catch (\Exception $e) {
47 // Extract API error response
48 $errorBody = null;
49 if (property_exists($e, 'body') && property_exists($e, 'statusCode')) {
50 $body = $e->body;
51 $errorBody = json_decode($body, true);
52 if (json_last_error() !== JSON_ERROR_NONE) {
53 $errorBody = $body;
54 }
55 } elseif (method_exists($e, 'getResponse')) {
56 $response = $e->getResponse();
57 if ($response !== null) {
58 $body = (string)$response->getBody();
59 $errorBody = json_decode($body, true);
60 if (json_last_error() !== JSON_ERROR_NONE) {
61 $errorBody = $body;
62 }
63 }
64 }
65
66 // Output API error response
67 if ($errorBody !== null) {
68 echo json_encode($errorBody, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
69 } else {
70 echo json_encode(['error' => $e->getMessage()], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
71 }
72 exit(1);
73}

After the video is processed, you can use the media ID to fetch playback info, monitor status, or transform content through the API.


Run the example

To execute the PHP script, use the following command. Make sure to replace index.php with your actual file name if it’s different:

$php index.php

NOTE

Some methods might throw errors when you are on a trial plan.


Changelog

All notable changes to this project will be documented in this file.

[1.0.4]

Changed

  • SDK version bump: 1.0.31.0.4. A maintenance release that updates the SDK’s internal version identifiers. It contains no functional, API, or behavioral changes and is fully backward compatible with 1.0.3.

    Updated identifiers:

    • sdkVersion constant — now reports 1.0.4.
    • User-Agent header — outbound requests now identify as fastpix-sdk/php 1.0.4.

Compatibility

  • No changes to public types, method signatures, request/response models, default server URLs, hooks, or retry logic.
  • No action required for existing integrations — update the dependency and rebuild.

[1.0.3]

⚠️ Important — FastPix is migrating from .io to .com

All FastPix hosts and documentation links are moving to the .com TLD:

Old (.io)New (.com)
api.fastpix.ioapi.fastpix.com
stream.fastpix.iostream.fastpix.com
images.fastpix.ioimages.fastpix.com
dashboard.fastpix.iodashboard.fastpix.com
www.fastpix.iowww.fastpix.com
docs.fastpix.io/...fastpix.com/docs/...

The .io hosts continue to serve traffic during the transition, but they are slated for deprecation soon — please update any hard-coded references in your application as part of your next deploy. We strongly recommend upgrading to this SDK release (or later) across every language you use — every official FastPix SDK is being rolled out with the same migration.

What this means for users of fastpix/sdk:

  • If you rely on SDK defaults, no code change is required. The default server URL is https://api.fastpix.com/v1/, so bumping to 1.0.3 and running composer update fastpix/sdk is enough.
  • If you have an explicit server-URL override (e.g. Fastpixsdk::builder()->setServerUrl('https://api.fastpix.io/v1/')), change it to https://api.fastpix.com/v1/.
  • If you reference FastPix asset URLs directly in your app (HLS playback URLs, image CDN, dashboard deep links), update those to the .com equivalents before .io is decommissioned.

All README and per-service doc links in this package have been updated to point at the new https://fastpix.com/docs/... URLs.

Fixed (SDK ↔ API parity)

  • manageVideos.listMedia (/on-demand): tracks now include frameRate, which was being silently dropped by the previous SDK build.
  • manageVideos.listMedia / getMedia / retrieveMediaInputInfo: audio tracks now retain languageCode and languageName — union deserialization previously resolved every track to the video track type and discarded the language fields.
  • playback.createMediaPlaybackId (/on-demand/{mediaId}/playback-ids): response data.resolution is now correctly modelled as nullable — it is null when no resolution constraint was set at create time.
  • signingKeys.deleteSigningKey (/iam/signing-keys/{signingKeyId}): response shape now includes the optional data.message confirmation string the API has been returning.
  • metrics.listOverallValues / metrics.getTimeseriesData: fixed a PSR-4 autoload mismatch (MetricsOverallmetadataDetails / MetricsTimeseriesmetadataDetails filename casing) that caused these calls to throw during deserialization.
  • OpenAPI tracks[].type for VideoTrack / VideoTrackForGetAll / AudioTrack / SubtitleTrack is now a proper enum (video / audio / subtitle) so the union can be discriminated correctly.
  • OpenAPI maxDuration.minimum on live-stream schemas relaxed from 60 to 0 to reflect the API’s “unbounded” sentinel value.

Docs

  • All README and per-service documentation pages updated from docs.fastpix.io/... and docs.fastpix.com/... to the new https://fastpix.com/docs/... URL structure.

[1.0.2]

Fixed

  • Fixed data event field remapping in hooks.

[1.0.1]

Fixed

  • Fixed missing parameters in multiple API methods.

Improved

  • Improved overall developer experience through more accurate typings.

[1.0.0]

Added

  • Media API: Upload media assets, list, fetch, update, and delete media
  • Generate and manage playback IDs
  • Live API: Create, list, update, and delete live streams
  • Support simulcasting to multiple platforms
  • AI-powered features: video summarization, chapter generation, content moderation
  • Analytics: view tracking, performance metrics, error monitoring
  • Security: signing key management and JWT token support
  • Playlist management: create, update, and manage playlists
  • DRM configuration support
  • Comprehensive error handling and retry logic
  • Full PHP 8.2+ type safety with PHPStan analysis
  • 163 unit and integration tests
  • Complete API coverage (100% of OpenAPI specification)

[0.1.0] - Beta

Added

  • Initial release of the SDK
  • Basic API endpoints
  • Core functionality