PHP code example of carboneio / carbone-sdk-php

1. Go to this page and download the library: Download carboneio/carbone-sdk-php 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/ */

    

carboneio / carbone-sdk-php example snippets


use Carboneio\SDK\Carbone;

$carbone = new Carbone('YOUR_API_KEY', 'https://api.carbone.io/');

$response = $carbone->templates()->upload($contentBase64);

$templateId = $response->getTemplateId();

$response = $carbone->renders()->render($templateId, $data);

$renderId = $response->getRenderId();

$response = $carbone->renders()->download($renderId);

// Save the contents of the file yourself on your filesystem
$content = $response->getContent();

$response = $carbone->templates()->delete($templateId);

$response = $carbone->templates()->download($templateId);

$carbone->setHeaders([
  "carbone-version" => 4,
  /** Uncomment to delete automatically templates after a specific time */
  // "carbone-template-delete-after" => 86400, // 86400s = 1 day | https://carbone.io/api-reference.html#template-storage
  // "carbone-webhook-url" => "https://my-server", // https://carbone.io/api-reference.html#api-webhook
]);

$response = $carbone->getStatus();
$json = $response->json();

echo "Status : " . $response->status() . "\n";
echo "Success: " . $json['success'] . "\n";
echo "Version: " . $json['version'] . "\n";
echo "Message: " . $json['message'] . "\n";
bash
composer