A PHP Integration for Transloadit's file uploading and encoding service
Transloadit is a service that helps you handle file uploads, resize, crop and watermark your images, make GIFs, transcode your videos, extract thumbnails, generate audio waveforms, and so much more. In short, Transloadit is the Swiss Army Knife for your files.
This is a PHP SDK to make it easy to talk to the Transloadit REST API.
composer require transloadit/php-sdk
Full documentation can be found over on transloadit.github.io/php-sdk
require_once 'vendor/autoload.php';
use Transloadit\Model\Auth;
use Transloadit\Factory\AssemblyResourceServiceFactory;
use Transloadit\Model\Step;
use Transloadit\Model\Parameter;
use Transloadit\Model\Resource\Assembly;
//This Auth you will use to all resources.
$auth = new Auth('your_key', 'your_secret');
//create a resource instance, this service will be used to consume assembly resource
$assemblyResource = AssemblyResourceServiceFactory::create($auth);
//create a step
$step1 = new Step('resize', [
'robot' => '/image/resize',
'width' => 200,
'height' => 100,
]);
$parameter = new Parameter([$step1]);
// you can add an step this way too $parameter->addStep($step1)
#create a assembly instance
$assembly = new Assembly($parameter);
$assembly->addFilePath('/PATH/TO/FILE.jpg');
#creating a assembly in transloadit api
$assembly = $assemblyResource->create($assembly);
/**
The $assembly variable will return an assembly object.
class Transloadit\Model\Resource\Assembly#34 (6) {
private $id =>
string(32) "your_id"
private $url =>
string(78) "http://api2.deoria.transloadit.com/assemblies/your_id"
private $sslUrl =>
string(79) "https://api2-deoria.transloadit.com/assemblies/your_id"
private $status =>
string(18) "ASSEMBLY_COMPLETED"
private $signature =>
...
*/