spatie

spatie/browsershot

PHP MIT Web Dev

Convert HTML to an image, PDF or string

5.2k stars
508 forks
active
GitHub

5.2k

Stars

508

Forks

0

Open issues

30

Contributors

5.4.0 26 May 2026

AI Analysis

Browsershot is a PHP library that converts HTML, URLs, and local files into images or PDFs using Puppeteer and headless Chrome. It's specifically designed for developers building PHP applications who need server-side screenshot or PDF generation capabilities, and is not a general-purpose tool—it's tightly integrated into PHP ecosystems and requires Puppeteer infrastructure. Best suited for Laravel applications, content management systems, and reporting tools that need programmatic rendering.

Web Dev Developer Tool Discovery value: 3/10
Documentation 8/10
Activity 10/10
Community 9/10
Code quality 7/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

html-rendering pdf-generation headless-chrome puppeteer screenshot
Actively maintained MIT licensed Popular Niche/specialized use case Beginner friendly Production ready
Deep Analysis · Based on README and public signals
19h ago

PHP wrapper around Puppeteer for HTML-to-PDF and screenshot generation

Browsershot is a PHP library from Spatie that converts HTML, URLs, or local files into images or PDFs by orchestrating a headless Chrome browser via Puppeteer under the hood. It is built primarily for Laravel and PHP developers who need server-side webpage rendering without managing raw browser automation. With 5,235 stars, 508 forks, over 10 years of history, and active maintenance as of July 2026, it occupies a well-established niche in the PHP ecosystem. The dependency on both Node.js and Puppeteer adds infrastructure complexity that may deter some users, but the trade-off is accurate, JavaScript-aware rendering.

Origin

Created in May 2014 by Freek Van der Herten at Spatie, it initially used PhantomJS (v1), then switched to headless Chrome CLI (v2), and later adopted Puppeteer for its current v3/v4 architecture. This evolution tracks the broader shift in headless browser tooling across the industry.

Growth

Growth was primarily driven by Spatie's strong reputation in the Laravel community and organic demand for PDF/screenshot generation in web apps. The project grew steadily over a decade rather than through a viral moment. Recent star velocity (0 in 7 days) suggests the project has plateaued in awareness — it likely already saturates its target audience — rather than declining in use.

In production

Packagist download badge is displayed prominently; total downloads are not quoted in the README excerpt, but the package has been available for over 10 years with consistent maintenance. The 508 forks and sustained star count are consistent with production usage. Adoption is plausible and likely substantial within the PHP/Laravel ecosystem, but specific production deployment numbers are not verified from available data.

Code analysis
Architecture

Appears to be a PHP class-based wrapper that shells out to a Node.js/Puppeteer script. Likely uses process spawning or similar IPC to communicate between PHP and the headless Chrome instance. The API is fluent/method-chaining style based on README examples. Requires both PHP (Composer) and Node.js (npm) environments to be available on the same host.

Tests

A test suite exists and is referenced in the README with a CI badge from GitHub Actions. Tests require Puppeteer and pdftotext (poppler-utils) to be installed, suggesting integration-level tests rather than pure unit tests. Exact coverage percentage not documented in README.

Maintenance

Last push was July 9, 2026 — the same day as this analysis — indicating active maintenance. CI is configured and passing according to the badge. Spatie as an organization has a strong track record of long-term package support. No signs of neglect.

Honest verdict

ADOPT IF: you are in a PHP/Laravel environment and need reliable rendering of JavaScript-heavy pages to PDF or images, and you can install Node.js and Puppeteer on your server or container. AVOID IF: your deployment environment prohibits Node.js installation, you need a fully PHP-native solution, or you are operating at very high throughput where per-request Chrome spin-up costs are prohibitive. MONITOR IF: you are evaluating Gotenberg or similar API-based alternatives as a way to decouple browser rendering from your PHP process — the architecture decision may matter more than the library itself.

Independent dimensions

Mainstream potential

3/10

Technical importance

6/10

Adoption evidence

6/10

Risks
  • Hard dependency on both Node.js and Puppeteer means two separate runtime stacks must be installed, versioned, and secured on the host — complicating deployment in shared hosting, restrictive containers, or locked-down environments.
  • Headless Chrome is resource-intensive; running many concurrent Browsershot jobs can exhaust server memory and CPU, requiring careful queueing and concurrency management that the library itself does not provide.
  • Puppeteer and Chrome update independently; breaking changes in Puppeteer's API have historically required Browsershot updates, creating occasional compatibility lag between Chrome versions and the PHP wrapper.
  • The PHP-to-Node process-spawning bridge introduces latency and potential failure modes (e.g., zombie processes, environment variable leakage) that are harder to debug than pure-PHP solutions.
  • Zero star growth in the observed 7-day window may indicate the project has reached saturation within its niche, meaning community momentum for new feature contributions may be limited going forward.
Prediction

Likely to remain a stable, well-maintained utility within the Spatie portfolio and the Laravel ecosystem for the foreseeable future. Unlikely to expand significantly beyond PHP developers. Containerized alternatives may gradually erode its install-base on cloud-native deployments.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

PHP
85.9%
JavaScript
14.1%

Information

Language
PHP
License
MIT
Last updated
1d ago
Created
148mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Open issues

No open issues — clean slate.

Open pull requests

No open pull requests.

Similar repos

KnpLabs

KnpLabs/snappy

Snappy is a PHP wrapper library for wkhtmltopdf and wkhtmltoimage that enables...

4.5k PHP Dev Tools
spatie

spatie/pdf-to-image

This PHP package converts PDF files to images (JPG, PNG, WebP, WEBP) using...

1.4k PHP Dev Tools
spatie

spatie/laravel-pdf

Laravel-pdf is a Laravel package that simplifies PDF generation by supporting...

1k PHP Web Dev
chrome-php

chrome-php/chrome

Chrome PHP is a PHP library for instrumenting headless Chrome/Chromium...

2.7k PHP Dev Tools
KnpLabs

KnpLabs/KnpSnappyBundle

KnpSnappyBundle is a Symfony bundle that wraps the Snappy PHP library to...

1.2k PHP Web Dev
vs. alternatives
wkhtmltopdf

wkhtmltopdf uses an older WebKit engine without JavaScript execution support. Browsershot's Puppeteer backend handles modern JS-heavy pages far better, but wkhtmltopdf has no Node.js dependency and is simpler to deploy on minimal servers.

mPDF / TCPDF

These are PHP-native PDF generators that construct PDFs from PHP code or HTML fragments. They don't render via a real browser, making complex CSS/JS layouts unreliable. Browsershot produces pixel-accurate output but at higher infrastructure cost.

Puppeteer (direct Node.js)

Puppeteer itself is the underlying engine. Using it directly in Node.js gives more control and avoids the PHP-to-Node bridge overhead, but Browsershot is the right choice when the rest of the stack is PHP and developers want to avoid switching contexts.

Playwright

Playwright is a more modern multi-browser automation framework with better cross-browser support. It lacks a mature PHP wrapper with Browsershot's API ergonomics, so PHP developers would need custom integration work.

Gotenberg

Gotenberg is a Docker-based API for PDF generation supporting multiple backends. It removes the Node.js-on-host requirement and is more suitable for containerized microservice architectures, but adds network call overhead and a separate service to manage.