sebastiansantillan / phpepub
A modern PHP library for creating EPUB3 files
v0.3.0-beta
2025-08-02 15:19 UTC
Requires
- php: >=8.3
- ext-dom: *
- ext-libxml: *
- ext-zip: *
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-08-02 15:45:49 UTC
README
A modern PHP library for creating EPUB files easily and efficiently.
🎉 Beta Version: v0.3.0-beta is production-ready with complete EPUB Accessibility 1.1 support!
Features
- ✅ Create EPUB 3.0 files
- ✅ Support for multiple chapters
- ✅ Metadata management (title, author, language, etc.)
- ✅ Support for images and CSS
- ✅ Complete EPUB Accessibility 1.1 support
- ✅ WCAG 2.1 Level AA compliance
- ✅ Schema.org accessibility metadata
- ✅ Fluent and easy-to-use interface
- ✅ Compatible with PHP 8.3+
Installation
Beta Version
composer require sebastiansantillan/phpepub:^0.3.0-beta
📝 Note: As this is an beta version, the API may change in future versions.
Basic Usage
<?php require_once 'vendor/autoload.php'; use PHPEpub\EpubBuilder; $epub = new EpubBuilder(); $epub->setTitle('My First Book') ->setAuthor('Your Name') ->setLanguage('en') ->setDescription('A book description'); // Add chapters $epub->addChapter('Chapter 1', '<h1>Chapter 1</h1><p>First chapter content...</p>'); $epub->addChapter('Chapter 2', '<h1>Chapter 2</h1><p>Second chapter content...</p>'); // Generate the EPUB file $epub->save('my-book.epub');
Accessibility Support
PHPEpub includes complete accessibility support for EPUB Accessibility 1.1:
$epub = new EpubBuilder(); $epub->setTitle('Accessible Book') ->setAuthor('Author Name') // Add accessibility metadata ->addAccessMode('textual') ->addAccessMode('visual') ->addAccessibilityFeature('structuralNavigation') ->addAccessibilityFeature('alternativeText') ->addAccessibilityHazard('none') ->setAccessibilitySummary('Fully accessible book with proper navigation and alt text') ->addConformsTo('EPUB Accessibility 1.1 - WCAG 2.1 Level AA'); $epub->addChapter('Chapter 1', '<h1>Accessible Chapter</h1><p>Content with proper structure...</p>'); $epub->save('accessible-book.epub');
Documentation
For more information, check the complete documentation.
Accessibility Documentation
- Complete Accessibility Guide - Detailed accessibility implementation
License
This project is licensed under the MIT License. See the LICENSE file for details.
Changelog
See CHANGELOG.md for changes in each version.