pubconnect / php-epub
php epub 解析器
1.3
2024-07-16 08:28 UTC
Requires
- php: >=7.0.0
- erusev/parsedown: 1.7.1
Requires (Dev)
- phpunit/phpunit: 6.2
- squizlabs/php_codesniffer: 3.*
This package is auto-updated.
Last update: 2024-09-16 09:40:36 UTC
README
关于 php-epub 库
php-epub 是一个 php 库,用于 epub 阅读器和创建器。我们可以使用它来读取电子书文件并将其提取到 CDN 域。
安装
使用 Composer
composer require lywzx/php-epub
{ "require": { "lywzx/php-epub": "^0.0.2" } }
require 'vendor/autoload.php' use lywzx\php-epub\EpubParser; $epubParser = new EpubParser('./alice.epub');
不使用 Composer
为什么你不使用 Composer?下载 php-epub 的最新版本 下载链接,并将 ZIP 归档的内容放入项目中的一个目录中。然后需要文件 autoload.php
以在需要时加载所有类和依赖项。
<?php require_once 'path_to_php-epub_directory/autoload.php'; use lywzx\php-epub\EpubParser; $epubParser = new EpubParser('./alice.epub');
epub 解析器使用示例
获取电子书信息
$epubParser = new EpubParser('./alice.epub'); // open file and check file is a validated epub $epubParser->parse(); // parser file var_dump($epubParser->getTOC()); // you will get the book category tree, e.g 1.0 var_dump($epubParser->getDcItem()); // you will get the book meta info, e.g 1.1 var_dump($epubParser->getDcItem('rights')) // Public domain in the USA.
例如 1.0
array(2) {
[1]=>
array(4) {
["id"]=>
string(4) "np-1"
["naam"]=>
string(22) "THE "STORYLAND" SERIES"
["src"]=>
string(65) "www.gutenberg.org@files@19033@19033-h@19033-h-0.htm#pgepubid00000"
["page_id"]=>
string(13) "pgepubid00000"
}
[3]=>
array(5) {
["id"]=>
string(4) "np-2"
["naam"]=>
string(32) "ALICE'S ADVENTURES IN WONDERLAND"
["src"]=>
string(65) "www.gutenberg.org@files@19033@19033-h@19033-h-0.htm#pgepubid00002"
["page_id"]=>
string(13) "pgepubid00002"
["children"]=>
array(11) {
[5]=>
array(5) {
["id"]=>
string(4) "np-3"
["naam"]=>
string(37) "SAM'L GABRIEL SONS & COMPANY NEW YORK"
["src"]=>
string(65) "www.gutenberg.org@files@19033@19033-h@19033-h-0.htm#pgepubid00004"
["page_id"]=>
string(13) "pgepubid00004"
["children"]=>
array(1) {
[7]=>
array(4) {
["id"]=>
string(4) "np-4"
["naam"]=>
string(57) "Copyright, 1916, by SAM'L GABRIEL SONS & COMPANY NEW YORK"
["src"]=>
string(65) "www.gutenberg.org@files@19033@19033-h@19033-h-0.htm#pgepubid00006"
["page_id"]=>
string(13) "pgepubid00006"
}
}
}
}
}
}
例如 1.1
array(9) {
["rights"]=>
string(25) "Public domain in the USA."
["identifier"]=>
string(37) "http://www.gutenberg.org/ebooks/19033"
["contributor"]=>
string(15) "Gordon Robinson"
["creator"]=>
string(13) "Lewis Carroll"
["title"]=>
string(32) "Alice's Adventures in Wonderland"
["language"]=>
string(2) "en"
["subject"]=>
array(2) {
[0]=>
string(7) "Fantasy"
[1]=>
string(24) "Fantasy fiction, English"
}
["date"]=>
array(2) {
[0]=>
string(10) "2006-08-12"
[1]=>
string(32) "2010-02-16T12:34:12.754941+00:00"
}
["source"]=>
string(56) "http://www.gutenberg.org/files/19033/19033-h/19033-h.htm"
}
更多示例请查看示例目录。
epub 创建器正在开发中。
文档即将发布。