mindtwo / statamic-flipbook
Statamic addon that turns uploaded PDFs into self-hosted, accessible page-flip flipbooks. Editors upload or replace a PDF, the conversion runs in the background.
Package info
github.com/mindtwo/statamic-flipbook
Type:statamic-addon
pkg:composer/mindtwo/statamic-flipbook
Requires
- php: ^8.2
- mindtwo/base-flipbook: ^1.0
- statamic/cms: ^5.0|^6.0
Requires (Dev)
- laravel/pint: ^1.13
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^2.34|^3.0|^4.0
- phpstan/phpstan: ^1.11|^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-01 16:28:07 UTC
README
Statamic addon that turns uploaded PDFs into self-hosted page-flip flipbooks — a replacement for
Yumpu or Issuu without ads, third-party trackers or a foreign domain. Built on
mindtwo/base-flipbook.
- No code for editors — add the Flipbook set, upload a PDF, save. The conversion runs in the background.
- New editions without downtime — Reupload the PDF in the asset browser: URL and references stay the same, visitors see the previous edition until the new one is complete. Replace or selecting another PDF points the content at a different file, which shows a placeholder with the PDF link until its own conversion is done.
- CP utility — Utilities → Flipbooks shows status, progress, errors and whether a PDF is tagged, and restarts a conversion.
- Accessible viewer — keyboard control, live announcements, server-side text version (also for
search engines), optional PDF download,
prefers-reduced-motion. - Neutral design adapted through CSS custom properties; light and dark variant.
- English and German interface.
Installation
Requirements: Statamic 5 or 6, PHP 8.2+ with GD, poppler-utils on the server
(sudo apt install poppler-utils, macOS: brew install poppler).
composer require mindtwo/statamic-flipbook php artisan storage:link
The viewer assets are published to public/vendor/flipbook whenever Composer runs
php artisan statamic:install (post-autoload-dump of every Statamic site), so they stay in sync
with each update. Without that script, run
php artisan vendor:publish --tag=flipbook-assets --force after every update.
To change defaults (asset containers, image widths, page limit, queue), publish the config:
php artisan vendor:publish --tag=flipbook-config
Queue
A conversion takes about 1–2 seconds per page. With QUEUE_CONNECTION=sync (local development)
the upload in the CP waits for it: the addon raises PHP's max_execution_time to timeout for the
conversion, but a proxy timeout (e.g. nginx fastcgi_read_timeout) can still cut off the request
for long PDFs. The frontend never starts a conversion on sync. Run a worker in production (Forge:
daemon):
php artisan queue:work --timeout=900
The job's time limit is timeout from the flipbook config (900 seconds); it overrides the
worker's --timeout. Laravel retries a job once retry_after of its connection has passed, so
retry_after must be a few seconds longer than timeout. The default is 90 seconds, so raise it
for the connection the conversions run on, e.g. a connection of its own in config/queue.php:
'flipbooks' => [ 'driver' => 'database', // or redis 'queue' => 'flipbooks', 'retry_after' => 960, ],
FLIPBOOK_QUEUE_CONNECTION=flipbooks FLIPBOOK_QUEUE=flipbooks
php artisan queue:work flipbooks --queue=flipbooks --timeout=900
A conversion that was killed is marked as failed and its temporary files are removed. One that
reports no progress for longer than timeout counts as abandoned and is started again the next
time the flipbook is shown. A queued conversion waits for the worker however long that takes; if
the queue was cleared, use Regenerate in the utility. Every upload and every Regenerate starts
a run of its own, an older run that is still converting stops and never replaces the newer
edition.
Usage
Import the fieldset into a Bard or Replicator set:
sets: main: display: Content sets: flipbook: display: Flipbook fields: - import: 'flipbook::flipbook'
and render the set:
{{ if type == "flipbook" }}
{{ flipbook :src="pdf" :title="title" :download="show_download" }}
{{ /if }}
The tag also works on its own:
{{ flipbook :src="my_pdf_field" class="my-12" }}
{{ flipbook src="assets::downloads/catalogue.pdf" :download="false" }}
| Parameter | |
|---|---|
src |
asset, assets field, asset ID or URL |
title |
shown above the flipbook (default: asset title or file name) |
download |
offer the PDF download (default true, recommended for accessibility) |
class |
additional classes, e.g. mt-flipbook--dark |
hash_key |
deep link prefix when a page has several flipbooks (default seite → #seite-12) |
Styling: override the --mt-flipbook-* custom properties, see
base-flipbook.
Caching
Every build has its own URL, and the tag writes it into the page. A new build goes live once it is complete; the previous one is kept until the next edition replaces it, so cached pages and open browser tabs keep working in between.
-
Static caching: when a build goes live, the addon applies the invalidation rules of the asset's container, as Statamic does when an asset is saved. Add rules for the pages that show flipbooks (or use
'rules' => 'all'), otherwise such pages keep the previous edition until they are invalidated otherwise. On Statamic 6, pages showing the placeholder are not cached.// config/statamic/static_caching.php 'invalidation' => [ 'rules' => [ 'assets' => [ 'assets' => ['urls' => ['/magazine', '/downloads/*']], // container handle ], ], ],
-
Other caches (
{{ cache }}, CDN): listen toMindtwo\Flipbook\Statamic\Events\FlipbookPublished($event->asset) and purge there, or render the tag inside{{ nocache }}.
Notes
- Generated pages live on the
publicdisk underflipbooks/{key}/{build}/. Every conversion writes a new build; the active one is switched afterwards, the previous one is kept and older builds are deleted. Deleting the PDF deletes its flipbook; moving or renaming it converts it again under the new path. - PDFs that existed before the addon was installed are converted the first time a page shows
them (on
sync: Regenerate in the utility). A PDF replaced on the server outside Statamic (deployment, FTP) keeps its cached metadata: runphp please assets:metaafterwards, which saves the assets and converts changed PDFs. - The text version is extracted automatically and depends on the PDF. Export PDFs as PDF/UA for full accessibility; the utility flags untagged files.
- The PDF itself stays a regular public asset. Disabling the download only hides the link.
Development
composer install
composer check # pint --test, phpstan (level 8), pest
Standalone, the core mindtwo/base-flipbook comes from Packagist; CI removes the path repository
base-flipbook when ../base-flipbook does not exist. To develop against unreleased core changes,
work in the monorepo mindtwo/flipbook.mindtwo.packages,
where the core resolves through that path repository. Feature tests convert a sample PDF and are skipped without poppler-utils.
License
MIT, see LICENSE.md.