承接 breuer/laravel-pdf-chrome-driver 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

breuer/laravel-pdf-chrome-driver

Composer 安装命令:

composer require breuer/laravel-pdf-chrome-driver

包简介

Chrome DevTools Protocol driver for spatie/laravel-pdf

README 文档

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

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.

统计信息

  • 总下载量: 680
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固