Snappy is a PHP library that generates thumbnails, snapshots, and PDFs from URLs or HTML pages by wrapping the wkhtmltopdf and wkhtmltoimage command-line tools.
The library solves the problem of converting web content to images and PDFs within PHP applications. It works by providing a thin wrapper around the webkit-based wkhtmltopdf and wkhtmltoimage binaries, which must be installed separately on the host system. Users can pass HTML content or URLs to Snappy and receive generated files, with support for customizing output through options passed to the underlying tools. The library can merge multiple URLs into a single PDF and supports various output modes including direct browser display, file downloads, and local file generation.
Snappy suits projects that need reliable HTML-to-PDF or HTML-to-image conversion within a PHP application. It works across OSX, Linux, and Windows. The README notes that wkhtmltopdf version 0.12.x is required, and it includes a security warning about the `--enable-local-file-access` option, which can expose local files or lead to remote code execution if used with untrusted HTML or JavaScript. The documentation recommends sanitizing user input, running wkhtmltopdf in a sandbox using AppArmor or SELinux, and considering alternatives like WeasyPrint, Prince, or Puppeteer for untrusted content. Framework integrations exist for Symfony, Laravel, and Zend Framework.
The project maintains continuous integration across multiple platforms and actively documents known issues in its FAQ, directing users there before opening new issues since many problems stem from the underlying wkhtmltopdf tool rather than Snappy itself. The maintainers are actively seeking additional contributors to help with ongoing maintenance.