PHP
Official PHP SDK for TemplateFox.
Installation
composer require templatefox/sdkGenerate a PDF
<?php
require_once __DIR__ . '/vendor/autoload.php';
use TemplateFox\Api\PDFApi;
use TemplateFox\Configuration;
use TemplateFox\Model\CreatePdfRequest;
// Initialize the client
$config = Configuration::getDefaultConfiguration()
->setApiKey('x-api-key', 'your-api-key');
$api = new PDFApi(null, $config);
// Generate a PDF
$request = new CreatePdfRequest([
'template_id' => 'YOUR_TEMPLATE_ID',
'data' => [
'name' => 'John Doe',
'invoice_number' => 'INV-001',
'total_amount' => 150.00,
],
]);
try {
$response = $api->createPdf($request);
echo "PDF URL: " . $response->getUrl() . "\n";
echo "Credits remaining: " . $response->getCreditsRemaining() . "\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}Configuration
$config = Configuration::getDefaultConfiguration()
->setApiKey('x-api-key', getenv('TEMPLATEFOX_API_KEY'));Full SDK Reference
For the complete API coverage including templates, account, S3 integration, and error handling, see the GitHub repository README .
Last updated on