Skip to content

WP Bones v3.4.1 is out! Check the Release Notes →

WP Bones
DocumentationAbout

Bones Console

/

Bones Command-Line Interface

Bones Command-Line Interface

This document explains the Bones command-line interface included with WP Bones Boilerplate. It provides helpful commands for plugin development. You can start by running php bones and change the plugin namespace using php bones rename "My First WP Bones Plugin". It highlights the importance of using double quotes for arguments with spaces on Windows. The document also covers the deploy command to create a folder for submitting your plugin to the WordPress.org repository.

Overview

Bones is also the name of the command-line interface included with all our WP Bones Boilerplate. It provides a number of helpful commands for your use while developing your plugin. You will use the Bones command-line interface to start your development. First of all, try the command-line console by running:

> php bones
PHP BonesPHP Bones

Then, you can change the plugin namespace from WPKirk to My First WP Bones Plugin, for example:

php bones rename "My First WP Bones Plugin"

Great! You are quite ready to start developing.

Common Commands

deploy

When your plugin is ready, you can use the deploy bones command in order to create a new folder useful to submit your plugin to the wordpress.org repository.

php bones deploy your-path/mydeploy

Remember that you can ask for help by using:

php bones deploy --help
Usage:
  deploy <path> <options>

Arguments:
  path		The complete path of deploy.

Options:
  --wp				You are going to release this plugin in the WordPress.org public repository.
  --create-zip			Creates an installable plugin zip file instead of deploying in a directory.
  --pkgm=<package-manager>	Forces the deployment to use the specified package manager, Eg. npm, yarn, ...
  --no-build			Forces the deployment to skip the build process.
  --keep-ignored		Packages files that git ignores as well (they are left out by default).
  --keep-dev			Packages Composer's require-dev packages as well (they are removed by default).
  --force			Replaces a destination folder that is neither empty nor a previous deploy of this plugin.

Where the deploy goes

The deploy deletes the destination folder and fills it again, so since v2.0.10 it checks the folder first, before anything is built:

  • the plugin itself, any folder that contains it (.., your home) and any folder inside it are always refused, --force or not;
  • an existing folder is replaced only when it is empty or holds a previous deploy of this plugin, that is its main file with the same Plugin Name;
  • anything else is left alone, and the deploy stops and says so. Pass --force if that folder really is yours to replace.

Since v3.3.1 a destination whose parent folders do not exist yet gets them, as mkdir -p would, once those checks have passed. A folder or file the deploy cannot write stops it with Deploy failed: could not write '<path>' and exit status 1.

What the deploy leaves out

Since v2.0.6 the deploy asks your plugin’s own git repository what it ignores and skips it, listing every path it left out. That is how a local POST.md stops travelling to WordPress.org: the file is invisible to git status, so nothing else in a release points at it.

Three directories are never consulted, because your repository’s ignore rules do not describe them: vendor/ is composer’s output and your plugin needs it at runtime, public/ holds what the build has just produced, and storage/ is the runtime directory. Most plugins gitignore all three.

Use --keep-ignored when an ignored file really does belong in the package. If the plugin is not a git repository, nothing is filtered.

Test suites

Since v3.2.0 the deploy leaves your plugin’s tests out of the package:

  • the PHP suite, where PHPUnit looks for it: tests/, phpunit.xml, phpunit.xml.dist and phpunit.dist.xml;
  • jest.config.js and jest.config.json;
  • every __tests__ folder, and every *.test.* or *.spec.* script (.ts, .tsx, .js, .jsx) outside vendor/ and node_modules/: the files the jest.config.js written by migrate:to-v2 runs, together with the __snapshots__ and __mocks__ folders Jest keeps beside them.

The last ones matter with --wp, which keeps resources/assets: up to v3.1.0 every Jest test in there went to WordPress.org with the scripts beside it, unless your deploy.php listed it. The cache PHPUnit writes, .phpunit.cache, never shipped, because the deploy skips every file and folder whose name starts with a dot. PHPUnit itself and the rest of your require-dev tree are removed as the next section explains.

If your composer.json loads a file from tests/ through autoload-dev’s files, the deploy stops and names it, rather than produce a plugin that fails as it loads. That only happens when the development autoloader reaches the package, with --keep-dev or with no require-dev package installed: move the file out of autoload-dev, or keep it in the package.

If your plugin really ships one of these paths, take it out of the default list in deploy.php:

add_filter('wpbones_console_deploy_default_skip_files_folders', function ($skip) {
    return array_values(array_diff($skip, ['/tests']));
});

Agent instructions

Since v3.3.0 the deploy leaves out the files coding agents read from a repository, wherever they are, vendor/ included:

  • AGENTS.md and AGENTS.override.md, read by Codex, Cursor, Copilot and most other agents, and AGENT.md;
  • CLAUDE.md and CLAUDE.local.md, Claude Code’s, a CLAUDE.md that links to AGENTS.md included;
  • GEMINI.md, Gemini CLI’s.

Up to v3.2.0 they shipped. A web server hands out a plugin’s files as they are, so a CLAUDE.md in the package, with whatever it says about your code, could be read at wp-content/plugins/<your-plugin>/CLAUDE.md on every site that installed the plugin. A deploy.php filter was no remedy when the package is built without WordPress, in a Docker build or a CI job, because deploy.php only runs when WordPress is loaded.

Their folders, .claude/, .codex/, .cursor/, .github/ and the like, never shipped: the deploy skips every file and folder whose name starts with a dot.

Composer dev packages

The deploy copies vendor/ as it is on disk, and a working copy normally has the require-dev tree installed — PHPUnit, Brain Monkey and the like. Up to v2.0.6 all of it went into the package, WordPress.org included, unless your deploy.php ran composer install --no-dev itself.

Since v2.0.7, when vendor/composer/installed.json lists dev packages, the deploy runs composer install --no-dev --no-scripts --no-plugins --optimize-autoloader in the deployed copy, against your plugin’s composer.lock. Your working copy is never touched, and --no-scripts keeps post-autoload-dump from renaming namespaces a second time. Without a composer.lock, or without Composer on the machine, the deploy stops rather than ship the dev packages. Pass --keep-dev to package them anyway.

The --wp option will create a deploy folder with the necessary files to submit your plugin to the WordPress repository. For further information, see Before submit to WordPress repository.

--wp

In the mydeploy folder, you will find only the necessary files to run your plugin. Without the --wp option the developer’s resources/assets folder will be removed.

Customize Deploy

Of course, you may customize the deployment process by editing the deploy.php file. In this file, you can add your own commands to run before and after the deployment. You will also find some actions and filters to customize the deployment process.

For example, you can add any custom command to run before the deployment by using:

/**
* Fired when the deploy command is started
*
* @param object $console Instance of WPBones Console
* @param string $path Destination path
*/
add_action('wpbones_console_deploy_start', function ($console, $path) {
    // Do something
}, 10, 2);

Or change the list of skipped files by using:

/**
* Filter the list of the folder to skip for the deploy version
*
* @param array $folders List of folders to skip
* @return array List of folders to skip
*/
add_filter('wpbones_console_deploy_skip_folders', function ($folders) {
    return $folders;
});

→ See more about Actions & Filters.

install

The install command is used to install the WP Bones framework. You can use the install command by running:

php bones install

→ See more about Installing WP Bones.

optimize

The optimize command uses the composer dump-autoload -o command to optimize the autoloader. You can use the optimize command by running:

php bones optimize

rename

The rename command is used to rename the plugin namespace. You can use the rename command by running:

php bones rename "My First WP Bones Plugin"

Since v2.1.0 the rename writes only the files whose content changes, and leaves binary files alone. Up to v2.0.12 it rewrote every file of the plugin, and a compiled .mo catalogue came out corrupted, because a longer plugin id shifts its strings while the offset table stays put.

→ See more about Naming your Plugin.

require

The require command is used to install third-party packages. You can use the require command by running:

php bones require <PackageName>

Under the hood the require command uses the composer require command. But it also renames the package name in the composer.json file.

We recommend using this command instead of composer require because by doing so, an automatic renaming will be performed.

tinker

The tinker command is used to open an interactive shell. You can use the tinker command by running:

php bones tinker

Now you can run any PHP code

>>> echo "Hello"
Hello

You can also use any WordPress function

>>> echo get_bloginfo('version');
6.6.2

A value you return is printed, variables live until the session ends, and an error is shown without closing the shell. The session ends with exit, with Ctrl-D, or when piped input runs out. Before v2.0.10 errors printed nothing, and piped input without a final exit never ended.

update

The update command updates the WP Bones framework and the packages it depends on:

php bones update

Since v2.1.0 it runs composer update wpbones/wpbones --with-dependencies and exits with Composer’s status. To update every package of your plugin, run composer update.

→ After updating the WP Bones framework, have a look at the Changelog to see what’s new.
→ And you may also check the Core Plugin Files to see if there are any changes.

version

The version command is used to version your plugin. You can use the version command by running:

php bones version 1.0.0

The above command updates the version everywhere your plugin declares it: the main plugin file, readme.txt, and — since v2.0.6 — package.json and the two root entries of package-lock.json. Each file it changes is listed:

→ readme.txt > 1.4.0 (Stable tag: 1.4.0)
→ wp-kirk.php  > 1.4.0 ( * Version: 1.4.0)
→ package.json > 1.4.0 (1 entry)
→ package-lock.json > 1.4.0 (2 entries)
✅ Version updated to 1.4.0

Your dependency tree is not touched: everything from the first "node_modules/" key of the lockfile onwards is left exactly as npm wrote it.

You can see the help by using:

php bones version --help
readme.txt > 1.4.0 (Stable tag: 1.4.0)
wp-kirk.php  > 1.4.0 ( * Version: 1.4.0)

Usage:
  version [plugin version]

Arguments:
  [plugin version]		    The version of plugin. Examples: '2.0',  'v1.2',  '1.2.0-rc.40', 'v1-beta.4'
  [--major]			        Increment the <major>.y.z of plugin.
  [--minor]			        Increment the x.<minor>.z of plugin.
  [--patch]			        Increment the x.y.<patch> of plugin.
  [--pre-patch] <prefix>	Increment the x.y.<patch>-<prefix>.<i> of plugin.
  [--pre-minor] <prefix>	Increment the x.<minor>.z-<prefix>.<i> of plugin.
  [--pre-major] <prefix>	Increment the <major>.y.z-<prefix>.<i> of plugin.

The php bones version command can handle the version starting from the current version of the plugin. You can use the following options:

--major

Increments the major version number. For example, if the current version is 1.0.0, the new version will be 2.0.0.

--minor

Increment the minor version number. For example, if the current version is 1.0.0, the new version will be 1.1.0.

--patch

Increment the patch version number. For example, if the current version is 1.0.0, the new version will be 1.0.1.

You can also use the --pre-patch, --pre-minor, and --pre-major options to increment the version with a prefix. For example, if the current version is 1.0.0, the new version will be 1.0.1-rc.1.

The default prefix is rc. But you can change it by using:

php bones version 1.0.0 --pre-patch beta

The above command will update the plugin version to 1.0.1-beta.1.

plugin

The plugin command is used to get and check your plugin. You can use the plugin command by running:

php bones plugin

You will see the current header of your main plugin file.

/**
 * Plugin Name: WP Kirk Demo
 * Plugin URI: https://github.com/wpbones/WPKirk
 * Description: WP Bones Demo WordPress plugin
 * Version: 1.6.1
 * Requires at least: 6.2
 * Requires PHP: 8.2
 * Author: Giovambattista Fazioli
 * Author URI: http://undolog.com
 * License: GPLv2 or later
 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: wp-kirk
 * Domain Path: languages
 *
 */

Check the help for more options:

php bones plugin --help
Usage:
 php bones plugin [options]
Available options:
 --check-header              Check the plugin header

--check-header

The --check-header option is used to check the plugin header. You can use the --check-header option by running:

php bones plugin --check-header

migrate:create

Creates a migration in database/migrations/, named with a Y_m_d_His timestamp and the table, from a stub that creates the table you give it:

php bones migrate:create Products
# → database/migrations/2026_10_06_142824_create_products_table.php

See Migrations.

migrate

New in v3.0. Runs the migrations that have not run on this site, in file name order, and lists them. It loads WordPress, so the plugin must sit in wp-content/plugins of a WordPress install. It exits with 1 when a migration fails.

php bones migrate

migrate:status

New in v3.0. Lists every migration and whether it ran on this site, with its batch and the plugin version it ran with, and the last failure if there is one.

php bones migrate:status

migrate:to-v3

New in v3.0. Converts a 2.x plugin to the breaking changes of WP Bones 3.0. Run it in the plugin’s source folder (not a deployed copy) after composer update has brought in WP Bones 3.0. It asks for a y first.

php bones migrate:to-v3
  • It rewrites the use line of every file in database/migrations/ to the 3.0 base class, WPBones\Database\Migration.
  • It turns every file in database/seeders/ into a migration, and deletes the seeder once its migration parses. See Seeding.
  • It lists, without changing them, the pages, menus and REST routes that 3.0 gives to administrators only, the POST forms that do not print $plugin->csrfField(), and the Ajax providers with logged actions and no $nonceHash.

Running it again changes nothing. See the full Migrating to v3 guide.

migrate:to-v2

New in v2.0. Converts a v1.x gulp-based plugin to the v2 webpack infrastructure.

php bones migrate:to-v2

The command removes gulpfile.js and package-lock.json, creates webpack.config.js, tsconfig.json, .prettierrc, .prettierignore and jest.config.js from the framework stubs, rewrites package.json scripts to the unified dev/build/test/format/lint block, drops gulp-era devDependencies, and installs the v2 set (@wordpress/scripts ^31, typescript, glob, less-loader, webpack-remove-empty-scripts, @types/react*, and prettier as wp-prettier). Your resources/assets/ tree is left untouched — your code is preserved.

After migration, run:

yarn install && yarn build

See the full Migrating to v2 guide for the end-to-end diff.

Creators

The Bones command console provides a set of commands to create some base classes. For example, you can create a Custom Post Type by using:

php bones make:cpt MyCustomPostTypeClass

Every creator that writes a PHP class takes a class name or Folder/ClassName (make:console takes a class name only, since the kernel loads plugin/Console/Commands/*.php), and the namespace follows the folder: php bones make:controller Shop/Cart writes plugin/Http/Controllers/Shop/Cart.php in …\Http\Controllers\Shop. make:app, below, takes an app name instead.

make:app

New in v2.0. Scaffolds a new React/TypeScript app under resources/assets/apps/. Webpack auto-discovers the new entry — no package.json edits needed.

php bones make:app dashboard
# → resources/assets/apps/dashboard/index.tsx (folder-based)

php bones make:app widget --flat
# → resources/assets/apps/widget.tsx (single-file)

Each generated app is a React 18 component using createRoot from @wordpress/element and __ from @wordpress/i18n, mounted on a #<name>-root div. The Text Domain is auto-resolved from your plugin header.

After scaffolding, add the mount div to your view and enqueue the bundle from your controller:

<div id="dashboard-root"></div>
return WPKirk()
  ->view('dashboard.index')
  ->withAdminAppsScript('dashboard');

Customizing the stubs

Every creator fills a stub: a template with placeholders such as {Namespace} and {ClassName}. Since v3.1.0 a stub in your plugin’s stubs/ folder comes first. make:controller reads stubs/controller.stub when it is there, and says so (Using stubs/controller.stub), and the framework’s own otherwise. Start from the framework’s:

php bones stub:publish                   # every stub
php bones stub:publish controller model  # only these

stub:publish never replaces a stub that is already in stubs/, since it is usually one you have edited: pass --force to take the framework’s again, and your changes go. deploy leaves the .stub files out of the package.

A published stub no longer follows the framework’s. After composer update wpbones/wpbones, compare yours with vendor/wpbones/wpbones/src/Console/stubs/.

StubWritten byPlaceholders
ajaxmake:ajax{Namespace}, {ClassName}, {Path}
apimake:api{Namespace}, {ClassName}, {Path}
appmake:app{AppName}, {ComponentName}, {TextDomain}
commandmake:console{Namespace}, {ClassName}, {Signature}, {CommandName}
controllermake:controller{Namespace}, {ClassName}, {Path}
cptmake:cpt{Namespace}, {ClassName}, {Path}, {ID}, {Name}, {Plural}
cttmake:ctt{Namespace}, {ClassName}, {Path}, {ID}, {Name}, {Plural}, {ObjectType}
eloquent-modelmake:eloquent-model{Namespace}, {ClassName}, {Path}, {Table}
kernelmake:console, when the plugin has no plugin/Console/Kernel.php yet{Namespace}, {ClassName}
migratemigrate:create{Namespace}, {Tablename}
modelmake:model{Namespace}, {ClassName}, {Path}
providermake:provider{Namespace}, {ClassName}, {Path}
schedulemake:schedule{Namespace}, {ClassName}, {Path}
shortcodemake:shortcode{Namespace}, {ClassName}, {Path}
widgetmake:widget{Namespace}, {ClassName}, {Path}, {PluginName}, {Slug}, {WidgetId}, {WidgetName}
webpack-config, tsconfig, jest-config, prettierrc, prettierignoremigrate:to-v2, for the files a plugin does not have yetnone

{Namespace} is your plugin’s namespace, {ClassName} the class without its folder, and {Path} the sub-namespace of the folder: \Shop for Shop/Cart, empty for Cart.