mikespub / epubli-epub
A PHP library for reading and manipulating contents and metadata of EPUB files.
1.0.2
2025-05-03 10:09 UTC
Requires
- php: >=8.2
- ext-dom: *
- ext-zip: *
- mikespub/epubli-common: ^1.0
Requires (Dev)
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2025-05-03 10:10:11 UTC
README
PHP library for reading metadata, document structure, and plain text contents from EPUB files.
Origin
This PHP EPUB library is a fork of splitbrain/php-epub-meta. The original code was changed quite a bit to fit our more conventional PHP coding standards in a symfony environment. Additional functionality includes reading the TOC/spine structure of EPUBs and extracting contents from contained XML files.
Installation
In your composer.json include the following:
{ "require": { "mikespub/epubli-epub": "^1.0" } }
Then do:
$ composer install
Usage
<?php // Open an EPUB file $epub = new Epubli\Epub\Epub('/path/to/your/book.epub'); // and read some of its metadata $title = $epub->getTitle(); $authors = $epub->getAuthors(); $desc = $epub->getDescription(); // Get the EPUB’s structural elements $toc = $epub->getToc(); $spine = $epub->getSpine(); // Iterate over the EPUB structure foreach ($spine as $spineItem) { // Get some text from the EPUB $chapterText = $spineItem->getContents(); // Or find all navigation points pointing to that spine item $navPoints = $toc->findNavPointsForFile($spineItem->getHref()); // Do something useful with the NavPoints. }