PHP code example of papi-ai / effect

1. Go to this page and download the library: Download papi-ai/effect 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/ */

    

papi-ai / effect example snippets


use PapiAI\Google\GoogleProvider;
use PapiAI\Effect\EffectVideo;

$effect = new EffectVideo(new GoogleProvider($apiKey));

// Describe the work as a lazy IO (nothing runs yet)
$io = $effect->generateVideoIO('a cat surfing a giant wave', ['durationSeconds' => 8]);

// Fork into a background fiber and carry on
$handle = $effect->generateVideoAsync('a cat surfing a giant wave', ['durationSeconds' => 8]);
// ... do other work ...
$video = $handle->await();      // VideoResponse
$video->save('surf.mp4');

$jobId = $effect->startVideoIO('a neon city at night')->unsafeRun();

foreach ($effect->progressStream($jobId)->toArray() as $status) {
    echo $status->status, "\n"; // running, running, ... completed
}