4 Ways to Set up a WordPress Plugin Boilerplate.

wp scaffold plugin my-plugin
npx wp-strap plugin
WPPB.me Boilerplate
composer init --type=wordpress-plugin
{
"name": "chigozieorunta/my-plugin",
"description": "A simple plugin to illustrate Composer boilerplate setup.",
"type": "wordpress-plugin",
"license": "GPL",
"authors": [
{
"name": "chigozieorunta",
"email": "chigozieorunta@yahoo.com"
}
],
"minimum-stability": "dev",
"require": {}
}
{
"name": "chigozieorunta/my-plugin",
"description": "A simple plugin to illustrate Composer boilerplate setup.",
"type": "wordpress-plugin",
"license": "GPL",
"authors": [
{
"name": "chigozieorunta",
"email": "chigozieorunta@yahoo.com"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"psr-4": {
"MyPlugin\\": "src/"
}
}

}
composer dumpautoload -o
"require": {},
composer install
<?phpnamespace MyPlugin;class HelloWorld {
private $message;
public function __construct() {
$this->message = "Hello World!\n";
}

public sayHello() {
return $this->message;
}
}
<?phprequire_once __DIR__ . '/vendor/autoload.php';$message = new MyPlugin\HelloWorld();echo $message->sayHello();
<?phprequire_once __DIR__ . '/vendor/autoload.php';use MyPlugin\HelloWorld;$message = new HelloWorld();echo $message->sayHello();
php index.php
Hello World!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store