PHPackages                             pressbooks/pb-cli - 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. [CLI &amp; Console](/categories/cli)
4. /
5. pressbooks/pb-cli

ActiveWp-cli-package[CLI &amp; Console](/categories/cli)

pressbooks/pb-cli
=================

A suite of wp-cli commands for Pressbooks.

3.1.0(3y ago)582.0k↓32.7%1[1 issues](https://github.com/pressbooks/pb-cli/issues)[1 PRs](https://github.com/pressbooks/pb-cli/pulls)1GPL-3.0-or-laterPHPPHP ^8.0CI failing

Since Oct 26Pushed 3mo ago8 watchersCompare

[ Source](https://github.com/pressbooks/pb-cli)[ Packagist](https://packagist.org/packages/pressbooks/pb-cli)[ Docs](https://github.com/pressbooks/pb-cli/)[ RSS](/packages/pressbooks-pb-cli/feed)WikiDiscussions dev Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (23)Used By (1)

pressbooks/pb-cli
=================

[](#pressbookspb-cli)

A suite of wp-cli commands for Pressbooks.

[![Build Status](https://camo.githubusercontent.com/dc9d63c286499be4ce45f68a73a3825ef10cbd7838c68bbcc48faed9b7ea9ea9/68747470733a2f2f7472617669732d63692e6f72672f7072657373626f6f6b732f70622d636c692e7376673f6272616e63683d70726f64756374696f6e)](https://travis-ci.org/pressbooks/pb-cli)

Quick links: [Using](#using) | [Installing](#installing) | [Contributing](docs/contributing.md#contributing) | [Support](docs/contributing.md#support)

Using
-----

[](#using)

This package implements the following commands:

### wp scaffold book-theme

[](#wp-scaffold-book-theme)

Generate the files needed for a Pressbooks book theme.

```
wp scaffold book-theme   [--theme_name=] [--description=] [--uri=] [--author=] [--author_uri=] [--github_account=] [--github_repo=] [--license=] [--textdomain=] [--version=] [--dir=] [--activate] [--enable-network] [--force]

```

Default behavior is to create the following files:

- functions.php
- .gitignore, .editorconfig, package.json, composer.json, composer.lock, yarn.lock
- README.md

Unless specified with `--dir=`, the theme is placed in the themes directory.

**OPTIONS**

```

	Slug for the new theme.

	Vendor for the new theme. Used in composer.json and package.json.

[--theme_name=]
	What to put in the 'Theme Name:' header in 'style.css'. Defaults to .

[--description=]
	Human-readable description for the theme.

[--uri=]
	What to put in the 'Theme URI:' header in 'style.css'.

[--author=]
	What to put in the 'Author:' header in 'style.css'.

[--author_uri=]
	What to put in the 'Author URI:' header in 'style.css'.

[--github_account=]
	The GitHub account that owns this project (e.g. 'pressbooks'). Defaults to vendor.

[--github_repo=]
	The GitHub repo name for this project (e.g. 'pressbooks-book'). Defaults to slug.

[--license=]
	What to put in the 'License:' header in 'style.css'.
	---
	default: GPL 2.0+
	---

[--textdomain=]
	Text domain for the theme. Defaults to .

[--version=]
	Version for the theme.
	---
	default: 1.0
	---

[--dir=]
	Specify a destination directory for the command. Defaults to the themes directory.

[--activate]
	Activate the newly created book theme.

[--enable-network]
	Enable the newly created book theme for the entire network.

[--force]
	Overwrite files that already exist.

```

### wp pb issue-template

[](#wp-pb-issue-template)

Generate an issue template for a Pressbooks theme or plugin, placing it in .github/ISSUE\_TEMPLATE.md.

```
wp pb issue-template  --type= --owner= [--dir=] [--force]

```

**OPTIONS**

```

	Slug for the theme or plugin (e.g. pressbooks, pressbooks-book).

--type=
	The type of repo for which we're generating an issue template. Must be `theme` or `plugin`.

--owner=
	The GitHub username of this repo's owner (e.g. pressbooks).

[--dir=]
	Specify a destination directory for the command. Defaults to the theme or plugin's directory.

[--force]
	Overwrite files that already exist.

```

### wp pb theme lock

[](#wp-pb-theme-lock)

Lock a book's theme.

```
wp pb theme lock --url=

```

**OPTIONS**

```
--url=
	The URL of the target book.

```

### wp pb theme unlock

[](#wp-pb-theme-unlock)

Unlock a book's theme.

```
wp pb theme unlock --url=

```

**OPTIONS**

```
--url=
	The URL of the target book.

```

### wp pb clone

[](#wp-pb-clone)

Clone a book.

```
wp pb clone   --user=

```

**OPTIONS**

```

	URL

	Book slug on the current network

--user=
	sets request to a specific WordPress user

```

### wp pb populate-books-admins

[](#wp-pb-populate-books-admins)

It populates `pb_book_admins` blog metada for each blog with comma-separated book administrator's user IDs.

### wp pb network-aggregate

[](#wp-pb-network-aggregate)

Aggregate Koko Analytics (visits &amp; referrers) across every site in a Pressbooks multisite using batched processing, retries and failure backoff.

```
wp pb network-aggregate [--mode=] [--batch-size=] [--start-id=] [--max-sites=] [--since-failures] [--lock-timeout=] [--retries=]

```

**OPTIONS**

```
--mode=
	Which data to aggregate. Default: both.

--batch-size=
	Number of blogs per batch (controls memory). Default: 200.

--start-id=
	Begin at this numeric blog ID (skip smaller IDs). Default: 0.

--max-sites=
	Stop after processing this many sites. Default: unlimited.

--since-failures
	Process only previously failed sites whose backoff has expired.

--lock-timeout=
	Seconds to wait for MySQL GET_LOCK before aborting gracefully. Default: 5.

--retries=
	Max attempts per blog+mode before recording a failure. Default: 3.

```

**BEHAVIOR**

- Uses a MySQL advisory lock (`GET_LOCK`) to prevent concurrent runs.
- Sequential batches scale to large networks without scanning all blogs each retry cycle.
- Failures stored with exponential backoff; `--since-failures` reprocesses only due rows.
- Exit codes: 0 (no failures), 2 (failures recorded), 1 (invalid mode/parameters).

**EXAMPLES**

Process entire network (both modes):

```
wp pb network-aggregate --mode=both --batch-size=200

```

Visits only with higher retry budget:

```
wp pb network-aggregate --mode=visits --retries=5

```

Retry only previously failed blogs:

```
wp pb network-aggregate --since-failures --batch-size=300

```

Stagger large networks (start at ID 1000, cap at 500 sites):

```
wp pb network-aggregate --start-id=1000 --max-sites=500

```

**TROUBLESHOOTING**

SymptomCauseFix`Cannot declare interface Mustache_Loader`Duplicate Mustache autoload (WP-CLI + plugin)Run with `--skip-plugins=pressbooks,pressbooks-network-analytics` or predefine `WP_CLI_SKIP_PLUGINS`"Another aggregation is running"Advisory lock held by another processRetry later or raise `--lock-timeout`Repeated failures for certain blogsPersistent data/plugin errorsUse `--since-failures`; inspect failure table entriesHigh memory usageBatch size too largeLower `--batch-size` (e.g. 100)Skip plugins if needed:

```
wp --skip-plugins=pressbooks,pressbooks-network-analytics pb network-aggregate

```

Failure table columns: blog\_id, mode, last\_error, attempts, last\_attempt\_at, next\_attempt\_at (cleared on success).

Internal logic (Runner, LockManager, BackoffStrategy, etc.) lives in `inc/NetworkStats/`.

Installing
----------

[](#installing)

Installing this package requires WP-CLI v2.5.0 or greater. Update to the latest stable release with `wp cli update`.

Once you've done so, you can install this package with:

```
wp package install git@github.com:pressbooks/pb-cli.git

```

Upgrade Notice
--------------

[](#upgrade-notice)

### 2.1.0

[](#210)

- PB-CLI requires Pressbooks &gt;= 5.21.0

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance49

Moderate activity, may be stable

Popularity36

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~130 days

Recently: every ~306 days

Total

18

Last Release

1279d ago

Major Versions

1.8.2 → 2.0.02019-03-22

2.1.0 → 3.0.02022-09-07

PHP version history (6 changes)1.6.0PHP &gt;=7.0

2.0.0PHP &gt;=7.1

2.1.0PHP &gt;=7.3

3.0.0PHP &gt;=7.4

3.0.1PHP ^7.4|8.0.\*

3.1.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5617ca8d230381ad60c37324c68fff5d0b1866a51f47b97e707a84afd0f80ce5?d=identicon)[pressbooks-ops](/maintainers/pressbooks-ops)

---

Top Contributors

[![greatislander](https://avatars.githubusercontent.com/u/605361?v=4)](https://github.com/greatislander "greatislander (19 commits)")[![SteelWagstaff](https://avatars.githubusercontent.com/u/13485451?v=4)](https://github.com/SteelWagstaff "SteelWagstaff (17 commits)")[![dac514](https://avatars.githubusercontent.com/u/812192?v=4)](https://github.com/dac514 "dac514 (12 commits)")[![arzola](https://avatars.githubusercontent.com/u/4997549?v=4)](https://github.com/arzola "arzola (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![fdalcin](https://avatars.githubusercontent.com/u/1761690?v=4)](https://github.com/fdalcin "fdalcin (3 commits)")[![danielbachhuber](https://avatars.githubusercontent.com/u/36432?v=4)](https://github.com/danielbachhuber "danielbachhuber (2 commits)")[![richard015ar](https://avatars.githubusercontent.com/u/13248424?v=4)](https://github.com/richard015ar "richard015ar (2 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (2 commits)")[![cmurtagh](https://avatars.githubusercontent.com/u/952104?v=4)](https://github.com/cmurtagh "cmurtagh (1 commits)")

---

Tags

automationbackendcli

### Embed Badge

![Health badge](/badges/pressbooks-pb-cli/health.svg)

```
[![Health](https://phpackages.com/badges/pressbooks-pb-cli/health.svg)](https://phpackages.com/packages/pressbooks-pb-cli)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M19](/packages/consolidation-annotated-command)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)[codedungeon/php-cli-colors

Liven up you PHP Console Apps with standard colors

10210.1M26](/packages/codedungeon-php-cli-colors)

PHPackages © 2026

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