1.0.8 ā€¢ Published 4 months ago

stacker-plugin-cli v1.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

STACKER-plugin-CLI : WordPress Plugin Developer Toolkit

WordPress Scaffolding Plugin Generator

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.

Version: v1.0.0 License npm Maintainer

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.

Stacker Pluigin CLI Questions Stacker Plugin Generated

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:

  1. Installation with Docker Compose : Choose Docker Compose as your development environment.
  2. Installation to be used with WP Local (https://localwp.com) : Choose WPLocal as your development environment.
  3. Installation with xdebug configured : From the options select 'Yes' for configuring xdebug.
  4. 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.