breuer/laravel-pdf-chrome-driver

Chrome DevTools Protocol driver for spatie/laravel-pdf
1,555 7
Install
composer require breuer/laravel-pdf-chrome-driver
Latest Version:v2.0.2
PHP:^8.2
Laravel:11 · 12 · 13
Older releases:10
License:MIT
Last Updated:Jul 13, 2026
Links: GitHub  ·  Packagist
Maintainer: breuer

Chrome DevTools Protocol driver for spatie/laravel-pdf

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

Configure the Chrome binary path and timeout in config/laravel-pdf.php:

'chrome' => [
    'path' => env('LARAVEL_PDF_CHROME_PATH'),
    'timeout' => env('LARAVEL_PDF_CHROME_TIMEOUT', 10),
],

Custom install directory

You can install to a custom directory with --path. Relative paths resolve from the project root:

# Install a specific Chrome milestone
php artisan pdf-chrome-driver:install 137

# Install to a custom directory
php artisan pdf-chrome-driver:install --path=storage/browser

# Absolute paths work too
php artisan pdf-chrome-driver:install --path=/opt/chrome

When using --path, configure the binary path so the driver can find it:

'chrome' => [
    'path' => storage_path('browser/chrome-headless-shell-linux64/chrome-headless-shell'),
],

This is useful for deployment tools like Envoyer where the vendor directory changes on each deploy but storage persists across releases.

Linux ARM64

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

LARAVEL_PDF_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.

Related Packages

spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

44,246,327 5,249
barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

28,627,638 2,754
elibyy/tcpdf-laravel

tcpdf support for Laravel 6, 7, 8, 9, 10, 11

3,183,375 357
codedge/laravel-fpdf

Laravel package to include Fpdf. It ships with Fpdf 1.86.

2,029,728 292
barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

119,195,391 7,286

Version History

Version Released PHP Laravel License
v2.0.2 ^8.2 ^11.0||^12.0||^13.0 MIT
v2.0.1 ^8.2 ^11.0||^12.0||^13.0 MIT
v2.0.0 ^8.2 ^11.0||^12.0||^13.0 MIT
v1.0.0 ^8.2 ^11.0||^12.0||^13.0 MIT
v0.3.1 ^8.2 ^11.0||^12.0||^13.0 MIT
Pre-releases (1)
Version Released PHP Laravel License
v1.0.0-alpha ^8.2 ^11.0||^12.0||^13.0 MIT