BookGlutton core epub read/write class in PHP. This standalone PHP class for the Epub (OEBPS 2.0) format has been battle-tested with over 20 publishers, including O'Reilly Media. Use it to do conversions from HTML, OPS filesystem manipulation, or direct zip container manipulation.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
BookGluttonEpub.php Revised test for getFlatNav and restored old function Dec 4, 2011
BookGluttonEpubFileFinder.php first commit Nov 1, 2011
H. G. Wells - The War of the Worlds.epub
test.php Revised test for getFlatNav and restored old function Dec 4, 2011



Copyright (c) 2011, Aaron Miller

Licensed under the MIT license.

Core class for the BookGlutton publishing and social reading platform. Includes OPS virtualization, zip container manipulation, and more, in a single convenient class library. Zip container and file finder helper classes included.


Requires epubcheck, zip, tidy, java, PHP mods for zip, dom_document, simple_xml, xpath, possibly others...

API documentation

Coming soon - There are many helpful convenience methods, and helpful comments, in the code. Please browse the main class file for more info on how to use this library.


1.Clean up the code! Production-tested but messy.
2.Add some test scripts and test epub/OPS content

Usage Examples:

Please see the test.php script for the simplest possible example of usage. More involved test scripts will be added when I get time. Do look through the main class file at some of the methods available. There is much useful there.

1. Open an epub from a file:

  $epub = new BookGluttonEpub();


2. Load an OPS structure into a virtualized Epub:

  $epub = new BookGluttonEpub();

3. Open a remote epub by URL and echo its ISBN:

  $epub = new BookGluttonEpub();

  echo $epub->getIsbn();
4. Open an epub as a virtual zip epub and unzip its contents into an OPS structure:
  $epub = new BookGluttonZipEpub();
  $epub->ingestZipData($zipdata, $book->getPackagePath());
5. Load remote, modify and save local to OPS:

  $epub = new BookGluttonEpub();





6. Create a new virtual OPS, then load an HTML conversion source, then save locally as OPS:
  $epub = new BookGluttonEpub();


  $epub->moveOps($ops_repo_root, $unique_package_directory_id);