eckinox/php-puppeteer
Generate PDFs in PHP using Puppeteer. Render from a URL or HTML string with a simple API and minimal dependencies. Includes setup guidance for installing Puppeteer/Chromium and basic examples for returning PDF output.
PdfGenerator facade)..nvmrc or Docker) to avoid Puppeteer breaks.xvfb or headless flags.Purifier or DOM sanitization).puppeteer/chromium images for consistency.Browser class supports this) to reduce overhead?dompdf (simpler, but less accurate)?snappy/dompdf for dynamic content (e.g., invoices, dashboards).pdf:generate job) to offload Chromium workloads.local, s3) for PDF storage.POST /pdf/generate)..nvmrc or engines in package.json).php-puppeteer.dompdf).// app/Services/PdfGenerator.php
class PdfGenerator {
public function generateFromHtml(string $html, array $options = []): string {
$browser = new Browser();
return $browser->pdf(['html' => $html, ...$options]);
}
}
// app/Jobs/GeneratePdfJob.php
class GeneratePdfJob implements ShouldQueue {
use Dispatchable, InteractsWithQueue;
public function handle() {
$pdf = app(PdfGenerator::class)->generateFromHtml($this->html);
Storage::put("pdfs/{$this->filename}.pdf", $pdf);
}
}
Browser once per worker (e.g., in Horizon).redis) to store generated PDFs for repeated requests.libgconf-2-4).xvfb for headless testing (e.g., GitHub Actions).['pdf' => ['format' => 'A4']]).goto and setCookie options for authenticated content.local-chromium updates for security patches.eckinox/php-puppeteer (e.g., via composer audit).retryAfter: 60).launchArgs to optimize Chromium.page.screenshot() to diagnose rendering issues.launchArgs: ['--enable-logging'].ulimit or Docker resource constraints to prevent OOM kills.r5.xlarge).OOM or Segmentation fault.How can I help you explore Laravel packages today?