breuer / laravel-pdf-chrome-driver
Chrome DevTools Protocol driver for spatie/laravel-pdf
Package info
github.com/jellebreuer/laravel-pdf-chrome-driver
pkg:composer/breuer/laravel-pdf-chrome-driver
Requires
- php: ^8.2
- ext-pcntl: *
- ext-zip: *
- guzzlehttp/guzzle: ^7.9
- illuminate/contracts: ^11.0||^12.0||^13.0
- react/async: ^4.3
- react/child-process: ^0.6.7
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/boost: ^2.4
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1
- orchestra/testbench: ^9.0.0||^10.0||^11.0
- pestphp/pest: ^3.0||^4.0
- pestphp/pest-plugin-arch: ^3.0||^4.0
- pestphp/pest-plugin-laravel: ^3.1||^4.0
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
- spatie/laravel-pdf: ^2.0
- stevebauman/autodoc-facades: ^1.2
Suggests
- spatie/laravel-pdf: Required to use this package as a driver for spatie/laravel-pdf (^2.0)
README
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
- PHP 8.2+
- Laravel 11+
- spatie/laravel-pdf ^2.0
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:
- Launches
chrome-headless-shellwith--remote-debugging-pipe - Communicates over CDP via file descriptors (fd 3/4) — no WebSocket, no port allocation
- Injects HTML via
Page.setDocumentContent— no temp files - 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.