To create video using PHP, you need an API capable of rendering dynamic video. The following example shows how to do that with Creatomate's PHP library. Perhaps you're developing a Laravel application for generating videos based on incoming data or user input. Here's how you'd accomplish this with just a few lines of code:
// composer require creatomate/creatomate
$client = new Creatomate\Client('Your API Key');
$output = $client->render([
// The ID of the template that you created in the online editor.
'template_id' => '2e8bccbf-e40a-41d5-a815-f58518ed9835',
// Inserting dynamic data into the template.
'modifications' => [
'Text' => 'Your Text And Video Here',
'Video' => 'https://cdn.creatomate.com/demo/drone.mp4'
])
]);
var_dump($output);
How it works: First, install the Creatomate package from Packagist using Composer. This PHP library makes it easier to work with Creatomate's video API. Creatomate is a managed API for generating video from your PHP application without managing your own infrastructure. It is as simple as invoking the API and receiving the MP4 file back.
There are several approaches to creating videos with PHP, but the easiest way is using a video template. This video template can be created using the online video editor. Once you have a template, you can reference the template in your PHP application and programmatically produce a video based on any given data. This is shown in the code example above. By using the "modifications" parameter, you can specify what data you want to insert into the template, whether it's text, video clips, or additional scenes.
Another way to make videos with PHP is to give the API video editing instructions. It lets you do any common video editing task straight from your PHP application, like stitching, merging, cropping, overlaying text, and more. You can see how in the related examples further down this page.
To get started, follow this quick tutorial or check out the API documentation.