Skip to content

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

WP Bones
DocumentationAbout
v3.4.1What's new in WP Bones

WordPress plugins with Laravel‑like bones.

WP Bones is a framework for WordPress plugins: service providers, Blade views, Eloquent models, migrations, and a bones command line that scaffolds, renames and deploys. Your plugin gets the shape of a modern PHP application, and still runs on any WordPress.

git clone -b main https://github.com/wpbones/WPKirk-Boilerplate.git my-plugin

Built with tools
you already know

  • WordPress
  • PHP & Composer
  • Eloquent
  • React
  • TypeScript
  • Mantine
  • Sass & Less
  • npm & Yarn

Every plugin deserves
a good skeleton.

WordPress gives a plugin hooks and a folder. WP Bones gives it a structure: the same tree in every plugin, from the boilerplate you start from to the build you deploy.

New in WP Bones 2 and 3

24 releases, and 404 tests behind them

From the webpack build of 2.0.0 to the secure defaults of 3.0.0: what changed, and the release that brought it.

Tested on every pull request

247 unit tests check the SQL the framework builds and who may open its pages, with no WordPress and no database. 157 more run the real bones file against throwaway plugins. Every pull request and every push to master runs them on PHP 8.1 to 8.4, and a deprecation fails the build.

tests at v3.4.1
404
assertions
1114
PHP versions in CI
4
67v2.0.4
148v2.0.10
200v2.1.2
350v3.0.0
The suite at the four releases that grew it most. The CI workflow
Run the test suite of WP Bones

A modern build

One webpack config on @wordpress/scripts finds every app, script and stylesheet in resources/assets. TypeScript and LESS work out of the box, and a v1 plugin moves over with php bones migrate:to-v2.

Read the docs on a modern build

A CLI that guards your files

deploy checks where it is going before it builds anything, generators never overwrite your files, and every failure exits non-zero. Since 2.1.0 bones runs from any folder and rename touches only what changes.

Read the docs on a cli that guards your files
The framework

Laravel's habits, inside WordPress

WP Bones has opinions about where things go: menus in config, logic in controllers, markup in Blade views, data in models and migrations. A plugin you open after six months reads like the one you wrote yesterday, and so does somebody else's.

  • A command line that scaffolds controllers, models, providers and apps
  • Eloquent and migrations on the WordPress database
  • React and TypeScript admin apps, built with @wordpress/scripts
  • 14 boilerplates to start from, each a working plugin
<?php
return [
  'wp_kirk_slug_menu' => [
    "page_title" => "WP Kirk Routes",
    "menu_title" => "WP Kirk Routes",
    'capability' => 'read',
    'icon' => 'wpbones-logo-menu.png',
    'items' => [
      [
        "page_title" => __('Menu Routing', 'wp-kirk'),
        "menu_title" => __('Menu Routing', 'wp-kirk'),
        'capability' => 'read',
        'route' => [
          'get' => 'MenuRouting\MenuRoutingController@index'
        ],
      ],
// ...
    ]
  ]
];
Scaffold the controller with bonesphp bones make:controller MenuRouting/MenuRoutingController

Admin menus are an array in config/menus.php, and each item routes to a controller method, as a Laravel route does. Read the docs on Routing

The bones command line

28 commands, one php bones away

Every plugin carries its own copy of the CLI. It scaffolds the files, renames the plugin, bumps the version everywhere it is declared, and packages the release.

$ php bones

Available commands:
 deploy                  Create a deploy version
 install                 Install a new WP Bones plugin
 optimize                Run composer dump-autoload with -o option
 plugin                  Perform plugin operations
 rename                  Rename the plugin name and the namespace
 require                 Install a WP Bones package
 tinker                  Interact with your application
 update                  Update the Framework
 version                 Update the Plugin version
migrate
 migrate                 Run the migrations that have not run on this site
 migrate:create          Create a new Migration
 migrate:status          List the migrations and whether each one ran
 migrate:to-v2           Migrate gulp-based plugin to v2 webpack infrastructure
 migrate:to-v3           Convert a 2.x plugin to the breaking changes of WP Bones 3
make
 make:ajax               Create a new Ajax service provider class
 make:api                Create a new API controller class
 make:app                Create a new React/TS app in resources/assets/apps
 make:console            Create a new Bones command
 make:controller         Create a new controller class
 make:cpt                Create a new Custom Post Type service provider class
 make:ctt                Create a new Custom Taxonomy Type service provider class
 make:eloquent-model     Create a new Eloquent database model class
 make:model              Create a new database model class
 make:schedule           Create a new schedule (cron) service provider class
 make:shortcode          Create a new Shortcode service provider class
 make:provider           Create a new service provider class
 make:widget             Create a new Widget service provider class
stub
 stub:publish            Copy the stubs into stubs/, where make:* reads them first

Scaffold, never overwrite

13 make: commands write controllers, models, providers and React apps into the right folder. None of them overwrites a file you already have, unless you pass --force.

$ php bones make:controller Dashboard/DashboardControllerLearn more about scaffold, never overwrite

Rename once, run beside any plugin

One command gives the boilerplate your plugin’s name, namespace, slug and main file. The framework’s own classes live under that namespace, so two plugins built on WP Bones never share a class on one site.

$ php bones rename "My First WP Bones Plugin"Learn more about rename once, run beside any plugin

Deploy only what ships

The deploy builds the assets and stops if the build fails, leaves out what git ignores and Composer’s dev packages, and with --wp prepares the folder for WordPress.org.

$ php bones deploy ../my-plugin-release --wpLearn more about deploy only what ships

A shell with WordPress loaded

Tinker runs any PHP and any WordPress function against your site, keeps variables for the session, and shows an error without closing.

$ php bones tinkerLearn more about a shell with wordpress loaded
Boilerplates

Start from 14 working plugins

One boilerplate per part of the framework, each a plugin you can open in your browser before you clone it. Pick the one closest to what you are building.

Ecosystem

Packages and tools around the framework

WP Bones for Raycast

The documentation and the boilerplates one keystroke away, on the Mac.

  • Search the documentation and open it in the browser
  • Search the boilerplates and start a plugin from one
  • See the latest version from the menu bar
  • Links to issues, FAQs and more
Get the extension
In production

Shipping on WordPress.org today

The framework this site documents is the one behind these five plugins, all published in the WordPress.org directory: Scotty and Bannerize on WP Bones 2, the other three on WP Bones 3.

Ready to give your plugin some bones?

Clone a boilerplate, run php bones install, and open the docs beside it.

git clone -b main https://github.com/wpbones/WPKirk-Boilerplate.git my-plugin