Gutenberg block development – is the newish development environment for everything, including plugins. The wp-env tool spins up a docker container running WP
The wp-env.json config file must be tweaked to run in my local server. I set port to 8887.
Blocks
Use npx @wordpress/create-block slug –wp-env to create a new block.
Start the server with wp-env start.
Plugins
To create a plugin, see the @wordpress/env package page for docs. The wp-env.json file will be:
{
"core": null,
"port": 8887,
"plugins": [ "." ]
}
I’m not sure how to scaffold a plugin with the CLI without a wordpress directory for reference (and I suspect it’s complicated because the core is installed somewhere else), so here’s a plugin template:
<?php
/**
* Plugin Name: PLG
* Description: Example block scaffolded with Create Block tool.
* Version: 0.1.0
* Requires at least: 6.7
* Requires PHP: 7.4
* Author: The WordPress Contributors
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: plg
*
* @package Plg
*/
Start the server with wp-env start.
Local WP Installation
Maybe there’s a way to use the local core files, and develop within there. This might be useful for some situation.