Download the PHP package kiwilan/php-ebook without Composer
On this page you can find all versions of the php package kiwilan/php-ebook. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kiwilan/php-ebook
More information about kiwilan/php-ebook
Files in kiwilan/php-ebook
Package php-ebook
Short Description PHP package to read metadata and extract covers from eBooks, comics and audiobooks.
License MIT
Homepage https://github.com/kiwilan/php-ebook
Informations about the package php-ebook
PHP eBook
PHP package to read metadata and extract covers from eBooks, comics and audiobooks.
Because metadata are the key against chaos.
- eBooks:
.epub
,.pdf
,.azw
,.azw3
,.kf8
,.kfx
,.mobi
,.prc
,.fb2
- Comics:
.cbz
,.cbr
,.cb7
,.cbt
(metadata from github.com/anansi-project) - Audiobooks:
.mp3
,.m4a
,.m4b
,.flac
,.ogg
with external packagekiwilan/php-audio
(MUST be installed separately)
To know more see Supported formats. Supports Linux, macOS and Windows.
[!NOTE]
This package favors eBooks in open formats such as
.epub
(from IDPF) or.cbz
(from CBA) and which be parsed with native PHP, so for the best possible experience we recommend converting the eBooks you use. If you want to know more about eBook ecosystem, you can read documentation.[!WARNING]
For DRM (Digital Rights Management) eBooks, in some cases you could read metadata but not contents (like HTML files for EPUB). To use all features, you have to use a software to remove DRM before using this package. For EPUB, you can use calibre with DeDRM plugin, this guide can help you.
About
This package was built for bookshelves-project/bookshelves
, a web app to handle eBooks.
Requirements
- PHP version
>=8.1
- PHP extensions:
- Binaries
p7zip
(optional) binarys for.CB7
(can handle.CBR
too)
- Audiobooks
kiwilan/php-audio
(optional) for.mp3
,.m4a
,.m4b
,.flac
,.ogg
(see Supported formats)
- To know more about requirements, see Supported formats
[!NOTE]
You have to install requirements only if you want to read metadata for these formats, e.g. if you want to read metadata from
.cbr
files, you have to installrar
PHP extension orp7zip
binary. So all requirements for PHP extensions and binaries are optional.[!WARNING]
Archives are handle with
kiwilan/php-archive
, for some formats (.cbr
and.cb7
)rar
PHP extension orp7zip
binary could be necessary. Some guides to install these requirements are available onkiwilan/php-archive
.
Features
- Support multiple formats, see Supported formats
- π Read metadata from eBooks, comics, and audiobooks
- πΌοΈ Extract covers from eBooks, comics, and audiobooks
- π΅ Works with audiobooks if
kiwilan/php-audio
is installed - π Support metadata
- eBooks:
EPUB
v2 and v3 from IDPF withcalibre:series
from Calibre |MOBI
from Mobipocket (and derivatives) |FB2
from FictionBook - Comics:
CBAM
(Comic Book Archive Metadata) :ComicInfo.xml
format from ComicRack and maintained byanansi-project
PDF
withsmalot/pdfparser
- Audiobooks:
ID3
,vorbis
andflac
tags withkiwilan/php-audio
(not included), based on audiobookshelf specifications
- eBooks:
- π Chapters extraction (
EPUB
only) - π¦
EPUB
andCBZ
creation supported - Works perfectly with
kiwilan/php-opds
: PHP package to generate OPDS feeds (not included)
Roadmap
- [ ] Better
.epub
creation support - [ ] Add
.epub
metadata update support - [ ] Add better handling of MOBI files:
libmobi
andebook-convert
from Calibre (fallback is available) - [ ] Add support of
ebook-convert
from Calibre - [ ] Add suport for DJVU:
djvulibre
Installation
You can install the package via composer:
Usage
With eBook files or audiobook* files (to know more about formats, see Supported formats).
*: should be installed separately, see Requirements.
For advanced description parsing, you can use getDescriptionAdvanced()
method with BookDescription
class.
For pages count, you can use these methods:
[!NOTE]
For performance reasons, with
EPUB
,pagesCount
andwordsCount
are only available on demand. If you usevar_dump
to check eBook, these properties will benull
.
Some metadata can be stored into extras()
method, without typing, directly from metadata.
[!NOTE]
For audiobooks, all metadata are stored into
extras
array, you will find duplicate withEbook::class
properties. See Formats specifications for more informations.
To know if eBook is valid, you can use isValid()
static method, before read()
.
To get additional data, you can use these methods:
To access to archive of eBook, you can use getArchive()
method. You can find more informations about archive in kiwilan/php-archive
.
And to test if some data exists:
Metadata
Ebook::class
contains many informations but if you want to access to raw metadata, metadata()
method is available.
MetaTitle
Can be set if book's title is not null.
You can customize slug with MetaTitle::class
:
Cover
Cover can be extracted from ebook.
[!NOTE]
- For
imagick
PHP extension.- For Audiobook, cover can be extracted with some formats.
Formats specifications
Audiobooks
For audiobooks, you have to install seperately kiwilan/php-audio
.
Specifications are based on audiobookshelf and ID3 tags. Metadata on audio files will be mapped as follows (second tag after "/" is a fallback):
Properties of Audio::class
are:
ID3 Tag (case-insensitive) | eBook |
---|---|
artist / album-artist |
Authors* |
album / title |
Title |
subtitle |
Extra property subtitle |
publisher |
Publisher |
year |
Publish Year |
composer |
Extra property narrators |
description |
Description |
genre |
Tags** |
series / mvnm |
Series |
series-part / mvin |
Volume |
language / lang |
Language |
isbn |
Identifiers isbn |
asin / audible_asin |
Identifiers asin |
Overdrive MediaMarkers | Extra property chapters |
- * Authors naming as well as multiple authors separated by
,
,;
,&
orand
. - ** Tags can include multiple tags separated by
/
,//
, or;
. e.g. "Science Fiction/Fiction/Fantasy"
You can find all metadata into getExtras()
array of Ebook::class
.
EPUB
With EPUB
, metadata are extracted from OPF
file, META-INF/container.xml
files, you could access to these metatada but you can also get chapters from NCX
file. And with chapters()
method you can merge NCX
and HTML
chapters to get full book chapters with label
, source
and content
.
[!NOTE]
For performance reasons, with
ncx
,html
andchapters
are only available on demand. If you usevar_dump
to check metadata, these properties will benull
.
Creation
You can create an EPUB or CBZ file with create()
static method.
[!NOTE]
Only
EPUB
andCBZ
are supported for creation.
Supported formats
There is a lot of different formats for eBooks and comics, if you want to know more about:
- Comparison of e-book formats for eBooks
- Comic book archive for comics
- Amazing MobileRead wiki
Name | Extensions | Supported | Uses | Support cover | Support series |
---|---|---|---|---|---|
EPUB (IDPF) | .epub |
β | Native zip |
β | β |
Kindle (Amazon) | .azw , .azw3 , .kf8 , .kfx |
β | Native filesystem |
β (See MOBI cover note) | β |
Mobipocket | .mobi , .prc |
β | Native filesystem |
β (See MOBI cover note) | β |
.pdf |
β | smalot/pdfparser (included) |
Uses imagick |
β | |
iBook (Apple) | .ibooks |
β | N/A | N/A | |
DjVu | .djvu , .djv |
β | N/A | N/A | |
Rich Text Format | .rtf |
β | N/A | N/A | |
FictionBook | .fb2 |
β | Native filesystem |
β | β |
Broadband eBooks | .lrf , .lrx |
β | N/A | N/A | |
Palm Media | .pdb |
β | N/A | N/A | |
Comics CBZ | .cbz |
β | Native zip |
β | β |
Comics CBR | .cbr |
β | rar PHP extension or p7zip binary |
β | β |
Comics CB7 | .cb7 |
β | p7zip binary |
β | β |
Comics CBT | .cbt |
β | Native phar |
β | β |
Audio | .mp3 , .m4a , .m4b , .flac , .ogg |
β | If kiwilan/php-audio is installed |
Depends of format | β |
MOBI cover note
Mobipocket files and derivatives (.mobi
, .prc
, .azw
, .azw3
, .kf8
, .kfx
) can have a cover image embedded in the file. With native solution of php-ebook
cover could be extracted but resolution is not good. Best solution is to convert file with calibre
and use EPUB
format.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
spatie
forspatie/package-skeleton-php
kiwilan
forkiwilan/php-archive
,kiwilan/php-audio
,kiwilan/php-xml-reader
- Ewilan Rivière author of this package
- All Contributors
License
The MIT License (MIT). Please see License File for more information.