PHPackages                             hametuha/hamepub - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hametuha/hamepub

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hametuha/hamepub
================

PHP Library to handle ePub 3.0

1.3.0(4mo ago)11.2kMITPHPPHP &gt;=8.2CI failing

Since May 26Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/hametuha/hamepub)[ Packagist](https://packagist.org/packages/hametuha/hamepub)[ Docs](https://github.com/hametuha/hamepub)[ RSS](/packages/hametuha-hamepub/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (6)Versions (7)Used By (0)

HamePub
=======

[](#hamepub)

[![GitHub actions for HamePub](https://github.com/hametuha/hamepub/actions/workflows/test.yml/badge.svg)](https://github.com/hametuha/hamepub/actions)

HemePub's living example is [hametuha](http://hametuha.com). It's a WordPress site which is able to publish it's contents to ePub.

If you maintain PHP-based web apps, HamePub will help your multi-publishing.

**NOTICE:** HamePub means nothing sexual. I wrote like this, because it sounds meaningful in Japanese. (HamePubはePub作成のためのPHPライブラリであり、エッチな出来事が起きるパブではありません）

How to Install
--------------

[](#how-to-install)

Use composer.

```
composer require haemtuha/hamepub
```

How to Use
----------

[](#how-to-use)

You can use HamePub for dynamic ePub generation, but for clarification, suppose that you have a static HTML collection like below:

```
dist
- index.html
- content.html
- colophon.html
- css
  - style.css
- img
  - cover.jpg
  - graph.jpg
  - barchart.png

```

Now we have CLI tool `hamepub` and you can run CLI command in your working directory.

```
# Dump setting file to default location (setting.json in project root).
./vendor/bin/hamepub init

# Or specify a custom file path.
./vendor/bin/hamepub init file=my-setting.json
```

Next, edit JSON file like below:

```
{
    "lang": "en",
    "root": "./dist/",
    "id": "my-first-ebook",
    "isbn": "1234567890123",
    "title": "My First Book",
    "author": "Fumiki Takahashi",
    "target": "./out",
    "published": "2023-01-01T23:00:00Z",
    "direction": "ltr",
    "cover": "./dist/img/cover.jpg",
    "toc": "Table of Contents",
    "header": {
        "max_level": 3,
        "depth": 2
    },
    "hidden": ["toc"]
}
```

### Setting Options

[](#setting-options)

KeyRequiredDescription`id`YesUnique identifier for the ePub (used as filename).`title`YesBook title.`author`YesAuthor name (string) or array of author objects.`published`YesPublication date in ISO 8601 format (e.g., `2023-01-01T23:00:00Z`).`root`NoDirectory containing HTML files. Default: `./dist/``target`NoOutput directory for the ePub file. Default: `./tmp``lang`NoLanguage code. Default: `en``isbn`NoISBN number.`direction`NoReading direction (`ltr`, `rtl`, or `default`). Default: `default``cover`NoPath to cover image.`toc`NoTable of contents title. Default: `Table of Contents``header.max_level`NoMaximum header level to include in TOC. Default: `3``header.depth`NoHeader depth. Default: `2``hidden`NoArray of HTML file names (without extension) to hide from spine. Default: `["toc"]``url_base`NoRegex pattern for URL replacement in assets. Default: `#\./#u``guides`NoArray of guide objects with `type`, `href`, and optional `title`.`properties`NoObject mapping HTML file names to arrays of properties.Then, run command.

```
# Generate ePub using default setting file (setting.json).
./vendor/bin/hamepub generate

# Or specify a custom setting file.
./vendor/bin/hamepub generate file=my-setting.json

# Specify a custom temporary directory.
./vendor/bin/hamepub generate tmp=./my-tmp-dir/
```

You will get ePub file `my-first-ebook.epub`.

Resources
---------

[](#resources)

Below are important resources.

- [ePub 3 Overview](https://www.w3.org/TR/epub-overview-33/)
- [Mark Code List for Relators](https://www.loc.gov/marc/relators/relaterm.html) is the definition of `author` section.

Acknowledgement
---------------

[](#acknowledgement)

The sample picture is credited by [Public Domain Pictures](https://www.pexels.com/ja-jp/photo/87742/) and [Nadi Lindsay](https://www.pexels.com/ja-jp/photo/3078831/).

License
-------

[](#license)

This library is released under [MIT](https://opensource.org/licenses/MIT).

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance74

Regular maintenance activity

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~418 days

Total

5

Last Release

145d ago

PHP version history (3 changes)1.0.0PHP &gt;=5.4

1.2.2PHP &gt;=7.2

1.3.0PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/84587?v=4)[Takahashi Fumiki](/maintainers/fumikito)[@fumikito](https://github.com/fumikito)

---

Top Contributors

[![fumikito](https://avatars.githubusercontent.com/u/84587?v=4)](https://github.com/fumikito "fumikito (60 commits)")

---

Tags

epubwordpressepub

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/hametuha-hamepub/health.svg)

```
[![Health](https://phpackages.com/badges/hametuha-hamepub/health.svg)](https://phpackages.com/packages/hametuha-hamepub)
```

###  Alternatives

[tgmpa/tgm-plugin-activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins).

1.8k222.5k13](/packages/tgmpa-tgm-plugin-activation)[aristath/kirki

Extending the WordPress customizer

1.3k73.0k4](/packages/aristath-kirki)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)[justintadlock/hybrid-carbon

God-like post featured image script.

202.5k](/packages/justintadlock-hybrid-carbon)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
