breuer/laravel-pdf-chrome-driver

Chrome DevTools Protocol driver for spatie/laravel-pdf

Maintainers

Package info

github.com/jellebreuer/laravel-pdf-chrome-driver

pkg:composer/breuer/laravel-pdf-chrome-driver

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 7

Open Issues: 1

v2.0.0 2026-04-04 08:38 UTC

This package is auto-updated.

Last update: 2026-04-04 09:16:11 UTC


README

Latest Version on Packagist Total Downloads GitHub Tests Action Status GitHub PHPStan Action Status GitHub Pint Action Status

A Chrome DevTools Protocol (CDP) driver for spatie/laravel-pdf. Renders PDFs by communicating directly with chrome-headless-shell over CDP pipes — no Node.js, no Puppeteer, no Docker, no external services.

Requirements

Installation

Install the package via Composer:

composer require breuer/laravel-pdf-chrome-driver

Download the headless Chrome binary:

php artisan pdf-chrome-driver:install

Set the driver in your config/laravel-pdf.php:

'driver' => 'chrome',

Or via your .env file:

LARAVEL_PDF_DRIVER=chrome

That's it. All spatie/laravel-pdf functionality now uses Chrome CDP under the hood.

Usage

This package is a driver for spatie/laravel-pdf — use spatie's API as documented in their README:

use Spatie\LaravelPdf\Facades\Pdf;

Route::get('/pdf', function () {
    return Pdf::view('invoice', ['order' => $order]);
});

Configuration

Publish the config file to customize Chrome binary path or timeout:

php artisan vendor:publish --tag="pdf-chrome-driver-config"
return [
    'path' => env('PDF_CHROME_DRIVER_CHROME_PATH'),
    'timeout' => env('PDF_CHROME_DRIVER_TIMEOUT', 10),
];

Linux ARM64

Pre-built Chrome binaries are not available for Linux ARM64. Install Chromium via your package manager and point to it:

PDF_CHROME_DRIVER_CHROME_PATH=/usr/bin/chromium

How it works

Unlike other drivers that shell out to Node.js or rely on external services, this driver:

  1. Launches chrome-headless-shell with --remote-debugging-pipe
  2. Communicates over CDP via file descriptors (fd 3/4) — no WebSocket, no port allocation
  3. Injects HTML via Page.setDocumentContent — no temp files
  4. Generates PDF via Page.printToPDF

Each request gets an isolated Chrome process with its own temp directory, cleaned up automatically.

License

This package is open-sourced software licensed under the MIT License. Please see the License File for more information.