PHP code example of opencoconut / coconut

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

    

opencoconut / coconut example snippets




nut = new Coconut\Client('k-api-key');

$coconut->notification = [
  'type' => 'http',
  'url' => 'https://yoursite/api/coconut/webhook'
];

$coconut->storage = [
  'service' => 's3',
  'bucket' => 'my-bucket',
  'region' => 'us-east-1',
  'credentials' => [
    'access_key_id' => 'access-key',
    'secret_access_key' => 'secret-key'
  ]
];




try {
  $job = $coconut->job->create([
    'input' => [ 'url' => 'https://mysite/path/file.mp4' ],
    'outputs' => [
      'jpg:300x' => [ 'path' => '/image.jpg' ],
      'mp4:1080p' => [ 'path' => '/1080p.mp4' ],
      'httpstream' => [
        'hls' => [ 'path' => 'hls/' ]
      ]
    ]
  ]);

  print_r($job);

} cacth(Exception $e) {
  echo $e->getMessage();
}


$job = $coconut->job->retrieve('OolQXaiU86NFki');

$metadata = $coconut->metadata->retrieve('OolQXaiU86NFki');
console
php composer.phar install