tregor/epub
Composer 安装命令:
composer require tregor/epub
包简介
description
README 文档
README
The EPub Generator is a powerful PHP library for creating EPub books. It provides a comprehensive set of features and an intuitive API to generate EPub files with ease. Whether you're a writer, publisher, or developer, this library will simplify the process of creating EPub books and help you deliver high-quality content to your readers.
Features
- Create EPub books from scratch
- Set book metadata such as title, author, and language
- Add chapters with custom titles, content, and order
- Remove, update, and rearrange chapters
- Export EPub books to standard EPub files
- Parse EPub files and retrieve book information
Requirements
- PHP 7.4 or higher
- XMLWriter extension
- Zip extension
Installation
You can install the package via composer:
composer require tregor/epub
Usage
Creating a New EPub Book
To create a new EPub book, you need to instantiate the EPubBook class and provide the book's title:
use tregor\epub\EPubBook; $book = new EPubBook('My First Book');
Parsing an Existing EPub Book
You can also parse an existing EPub book and retrieve its information. To do this, use the open method:
$book = EPubBook::open('existing_book.epub');
Setting Book Metadata
You can set the author and language of the book using the setAuthor and setLanguage methods:
$book->setAuthor('John Doe'); $book->setLanguage('en');
Adding Chapters
You can add chapters to the book using the addChapter method. Each chapter requires a title, content, and order:
$book->addChapter('Chapter 1', 'This is the first chapter.', 1); $book->addChapter('Chapter 2', 'This is the second chapter.', 2);
Rearranging Chapters
You can add a new chapter after an existing chapter by specifying the order of the existing chapter, the title and content of the new chapter, and the new order:
$book->addChapterAfter(1, 'Chapter 2', 'This is the new Chapter 2.', 2);
Removing Chapters
To remove a chapter from the book, specify its order:
$book->removeChapter(2);
Updating Chapters
You can update the content of a chapter by specifying its order and providing the new content:
$book->setChapterContent(1, 'This is the updated content of Chapter 1.');
Exporting the EPub Book
Once you have added all the chapters, you can export the EPub book to a file using the export method:
$book->export('my_first_book.epub');
Available Methods
Here are the available methods provided by the EPubBook class:
__construct($title): Creates a newEPubBookobject with the specified title.addChapter($title, $content, $order): Adds a new chapter to the book with the specified title, content, and order.removeChapter($order): Removes a chapter from the book with the specified order.addChapterAfter($order, $title, $content, $newOrder): Adds a new chapter after an existing chapter with the specified order, title, content, and new order.getChapterContent($order): Retrieves the content of a chapter with the specified order.setChapterContent($order, $content): Updates the content of a chapter with the specified order.export($filename): Exports the book to an EPub file with the specified filename.getTitle(): Retrieves the title of the book.setTitle($title): Sets the title of the book.getAuthor(): Retrieves the author of the book.setAuthor($author): Sets the author of the book.getLanguage(): Retrieves the language of the book.setLanguage($language): Sets the language of the book.
TODO
Here is a list of features that we plan to implement in future releases:
- Support for adding a table of contents
- Support for adding a cover image
- Support for adding additional metadata
- Improved error handling and exception handling
License
The EPub Generator is proprietary software. See the license file for more information.
Contributing
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
Credits
The EPub Generator library is developed and maintained by tregor.
Keywords
EPub, EPub Generator, PHP, Library, EPub Book, EPub Format, EPub Files, EPub Creation, EPub Parser, EPub Writer, EPub Library, EPub PHP Library, EPub Generator PHP, EPub Generator Library, EPub Generator PHP Library, EPub Generator Example, EPub Generator Usage, EPub Generator Documentation, EPub Generator Tutorial, EPub Generator Guide, EPub Generator Features, EPub Generator Requirements, EPub Generator Installation, EPub Generator API, EPub Generator Methods, EPub Generator TODO, EPub Generator License, EPub Generator Contributing, EPub Generator Credits
tregor/epub 适用场景与选型建议
tregor/epub 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tregor/epub 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tregor/epub 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 44
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2023-10-06