docfast/sdk/laravel
DocFast Bot bc67c52d3a
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled
feat: add Go, PHP, and Laravel SDKs
- Go SDK: zero deps, functional options pattern, full endpoint coverage
- PHP SDK: PHP 8.1+, curl-based, PdfOptions class, PSR-4 autoloading
- Laravel package: ServiceProvider, Facade, config publishing
- All SDKs document complete PDF options including new v0.4.5 params
2026-02-21 13:29:48 +00:00
..
config feat: add Go, PHP, and Laravel SDKs 2026-02-21 13:29:48 +00:00
src feat: add Go, PHP, and Laravel SDKs 2026-02-21 13:29:48 +00:00
composer.json feat: add Go, PHP, and Laravel SDKs 2026-02-21 13:29:48 +00:00
README.md feat: add Go, PHP, and Laravel SDKs 2026-02-21 13:29:48 +00:00

DocFast for Laravel

Official Laravel integration for the DocFast HTML/Markdown to PDF API.

Installation

composer require docfast/laravel

Add your API key to .env:

DOCFAST_API_KEY=df_pro_your_api_key

Publish the config (optional):

php artisan vendor:publish --tag=docfast-config

Usage

Via Facade

use DocFast\Laravel\Facades\DocFast;

// HTML to PDF
$pdf = DocFast::html('<h1>Invoice</h1><p>Total: €99.00</p>');
return response($pdf)
    ->header('Content-Type', 'application/pdf')
    ->header('Content-Disposition', 'inline; filename="invoice.pdf"');

Via Dependency Injection

use DocFast\Client;

class InvoiceController extends Controller
{
    public function download(Client $docfast)
    {
        $pdf = $docfast->html(view('invoice')->render());
        return response($pdf)
            ->header('Content-Type', 'application/pdf');
    }
}

Markdown to PDF

$pdf = DocFast::markdown('# Report\n\nGenerated at ' . now());

URL to PDF

$pdf = DocFast::url('https://example.com');

With PDF Options

use DocFast\PdfOptions;

$options = new PdfOptions();
$options->format = 'Letter';
$options->landscape = true;
$options->margin = ['top' => '20mm', 'bottom' => '20mm'];

$pdf = DocFast::html($html, null, $options);

Headers and Footers

$options = new PdfOptions();
$options->displayHeaderFooter = true;
$options->footerTemplate = '<div style="font-size:9px;text-align:center;width:100%">Page <span class="pageNumber"></span></div>';
$options->margin = ['top' => '10mm', 'bottom' => '20mm'];

$pdf = DocFast::html(view('report')->render(), null, $options);

Templates

$pdf = DocFast::renderTemplate('invoice', [
    'company' => 'Acme Corp',
    'items' => [['name' => 'Widget', 'price' => 9.99]],
]);

Configuration

// config/docfast.php
return [
    'api_key' => env('DOCFAST_API_KEY'),
    'base_url' => env('DOCFAST_BASE_URL', 'https://docfast.dev'),
    'timeout' => env('DOCFAST_TIMEOUT', 60),
];