stacker-plugin-cli v1.0.8
STACKER-plugin-CLI : WordPress Plugin Developer Toolkit
A Zero-Configuration WordPress plugin development toolkit that kickstarts your next WordPress plugin development project with modern tools and workflows.
Out-Of-The-Box Support For: Classes & Functions Autoloading, Gutenberg Blocks, Xdebug, PHPUnit tests, Docker-Compose, LocalWP, WordPress Coding Standards, JavaScript & SCSS lints, Husky hooks to make sure that you always commit error-free code, and VSCode configs to configure your IDE to setup perfectly for your plugin development experience.
Stacker Plugin Boilerplate Supports
- Classes & Functions auto-loading for 'inc' folder
- Optional GutenBerg Blocks development
- Docker Compose or wpLocal development envrionment
- Xdebug for VScode
- PHPUnit test
- Composer dependencies
- NPM dependencies
- WordPress Coding Standards, WooCommerce Coding Standards & Fixes via PHPCS/PHPCBF
- Gulp, SASS, Babel, Webpack, AutoPrefixer, BrowserSync (Reloads your browser while development), assets minification and image optimizations.
š How the CLI works?
Stacker-plugin-cli asks a set of questions required to scaffolds your WordPress plugin.
:arrow_right: Quick Installation
In your terminal window; cd to your plugin development folder 'wp-content/plugins' and run the below given npx command:
$ npx stacker-plugin-cli
You will be asked a few questions to generate & configure your plugin files, answer them correctly and a fresh WordPress plugin boilerplate will be generated inside your current working directory (which usually, should be your wp-content/plugins) folder.
Once the files are generated successfully, cd to your generated plugin's directory and install npm and composer dependencies.
$ cd Your-Plugin-Folder
$ npm install
$ composer install
Now, you can start building your plugin using the npm command below:
$ npm run start
:open_file_folder: Generated Plugin's Folder Structure with docker compose, xdebug, and phpunit configured
./plugin-name
āāā Dockerfile '(Dockerfile to build images in docker compose)'
āāā blocks.webpack.config.js '(webpack config for wpscript)'
āāā composer.json '(composer json)'
āāā docker-compose.yaml '(docker compose yaml file)'
āāā docker-configs '(config files for docker compose env)'
āĀ Ā āāā php-file-size.ini
āĀ Ā āāā xdebug.ini
āāā inc '(inc folder of our plugin)'
āĀ Ā āāā admin
āĀ Ā āĀ Ā āāā class-admin.php '(contains the admin class of our plugin)'
āĀ Ā āĀ Ā āāā class-hooks.php '(contains admin hooks of our plugin)'
āĀ Ā āĀ Ā āāā index.php
āĀ Ā āāā class-autoloader.php '(Our plugin classes autoloader. Works for files inside 'inc' folder only)'
āĀ Ā āāā class-loader.php '(Our plugin loader class to bootstrap the plugin)'
āĀ Ā āāā helpers '(Helper functions of our plugin. Any file with *-functions.php name will be autoloaded)'
āĀ Ā āĀ Ā āāā helper-functions.php
āĀ Ā āĀ Ā āāā index.php
āĀ Ā āāā index.php
āĀ Ā āāā public '(Frontend functionality classes of our plugin goes here.)'
āĀ Ā āĀ Ā āāā class-frontend.php
āĀ Ā āĀ Ā āāā index.php
āĀ Ā āāā repositories '(Any class deals with creating repositories lies here.)'
āĀ Ā āĀ Ā āāā class-user.php
āĀ Ā āĀ Ā āāā index.php
āĀ Ā āāā services '(Any class for different services lies here. e.g. api or db queries)'
āĀ Ā āāā class-api.php
āĀ Ā āāā class-db.php
āĀ Ā āāā index.php
āāā index.php
āāā package.json '(npm packages definition file)'
āāā phpunit.xml.dist '(file to configure options for PHPUnit)'
āāā plugin-name.php '(Our main plugin file)'
āāā src '(contains source files for blocks and plugin assets)'
āāā assets '(plugin common frontend and backend assets)'
āāā blocks '(gutenberg blocks files)'
ā”ļø Begin Installation
ā”ļø Create a fresh plugin in your plugin's folder
In your terminal window; cd to your plugin development folder 'wp-content/plugins/' and run the below given npx command:
$ npx stacker-plugin-cli
You will be asked a few questions to generate & configure your plugin files, answer them correctly and a fresh WordPress plugin boilerplate will be generated inside your current working directory (which usually, should be your wp-content/plugins) folder.
$ npm run start
Start your development environment to watch changes in your PHP, Js, and SCSS files.
$ composer run phpcs
To sniff your plugin's php files for WordPress coding standards.
$ composer run phpcbf
To fix WordPress coding standards errors within your plugin's directory.
ā”ļø Installation Configuration Options Available
In the CLI questions you will be asked to pick these options to generate the plugin files depending on your development:
- Installation with Docker Compose : Choose Docker Compose as your development environment.
- Installation to be used with WP Local (https://localwp.com) : Choose WPLocal as your development environment.
- Installation with xdebug configured : From the options select 'Yes' for configuring xdebug.
- Installation with PHPUnit configured : From the options select 'Yes' for configuring PHPunit.
ā”ļø How to run php tests?
$ npx stacker-plugin-cli
Run PHP tests by running below command in your generated plugin's folder:
$ composer run test
ā”ļø NPM Commands available
npm run build
: To build your plugin files with blocks and other assets.npm run start
: To start watching your development changes in JS, IMG, and SCSS files in src/blocks and src/assets folder. Kicks hot-reloading as well.npm run dist
: To create a distributable version of plugin and zip file.npm run devdist
: To create a distributable version of plugin for other fellow developers who don't have access to your private git repo.npm run format
: To format your plugin's SCSS and Js files.
ā”ļø Composer Commands available
composer run test
: To run php tests defined in ./tests/ directory of your plugin.composer run phpcs
: To execute PHP Code Sniffer with WordPress coding standards on your plugin files.composer run phpcbf
: To execute PHP Code Beautifier with WordPress coding standards on your plugin files to fix PHPWPCS errors in your plugin files.