Documentation

EpubArchive

FinalYes

Read-only accessor over the ZIP container of an EPUB.

An EPUB is a ZIP archive with a prescribed internal layout. This class owns the archive handle and nothing else: locating and interpreting the entries is EpubReader's job.

Entry lookups are case-insensitive on the stored path, because real EPUBs in the wild disagree about the casing of META-INF/container.xml.

Tags
since
3.4.0

Table of Contents

Properties

$index  : array<string, string>
Lowercased entry name => actual entry name, for case-insensitive lookup.
$zip  : ZipArchive

Methods

close()  : void
Close the underlying archive handle.
has()  : bool
Whether an entry exists in the archive.
normalize()  : string
Collapse `.` / `..` segments and strip a leading slash from a ZIP path.
open()  : self
Open an EPUB archive for reading.
read()  : string|null
Read one entry's contents.
__construct()  : mixed

Properties

$index

Lowercased entry name => actual entry name, for case-insensitive lookup.

private array<string, string> $index = []

Methods

close()

Close the underlying archive handle.

public close() : void

has()

Whether an entry exists in the archive.

public has(string $path) : bool
Parameters
$path : string
Return values
bool

normalize()

Collapse `.` / `..` segments and strip a leading slash from a ZIP path.

public normalize(string $path) : string

EPUB hrefs are relative to the document that references them, so resolving them produces paths like OEBPS/text/../images/cover.jpg that must be flattened before they will match a stored entry name.

Parameters
$path : string
Return values
string

open()

Open an EPUB archive for reading.

public static open(string $filePath) : self
Parameters
$filePath : string

Absolute path to the EPUB on disk

Tags
throws
RuntimeException

When the file is not a readable ZIP archive

Return values
self

read()

Read one entry's contents.

public read(string $path) : string|null
Parameters
$path : string

Entry path inside the archive

Return values
string|null

Contents, or null when the entry is absent or unreadable

__construct()

private __construct(ZipArchive $zip) : mixed
Parameters
$zip : ZipArchive
On this page

Search results