Skip to content

CLI Overview

Xe Plugin includes a native, lightweight PHP command-line runner (xe) that eliminates external build tools like Node.js, Gulp, or Webpack for scaffolding and release generation.


How It Works

The executable script xe is located at the root of the plugin directory. When invoked with PHP:

php xe [command] [arguments...]
  1. It requires Composer's vendor/autoload.php.
  2. It initializes the XePlugin\CLI\Console router.
  3. It resolves the command and executes the corresponding handler class in cli/Commands/.

Available Commands

Running php xe without arguments displays all registered commands:

Xe Plugin CLI

Available commands:
  init
  build
  docs
  make:module
  make:sequence
  make:elementor

Command Summary

Command Arguments Description
init None Replaces boilerplate names, prefixes, text-domains, and renames the main plugin file according to config.json.
build None Generates a clean production build at the target path specified in config.json and compiles translation .pot files.
docs None Deploys documentation to GitHub Pages using mkdocs gh-deploy --force.
make:module <Name> Scaffolds a new CRUD business module controller in src/Modules/.
make:sequence <Name> Scaffolds a custom auto-incrementing database sequence table in src/Database/Sequences/.
make:elementor <Name> Scaffolds a custom Elementor widget class in src/Elementor/.

Architecture of the CLI

The CLI tool lives under the cli/ folder:

cli/
├── Commands/
│   ├── Build.php          # Build command handler
│   ├── Docs.php           # MkDocs deploy command handler
│   ├── Init.php           # Project initialization handler
│   ├── MakeElementor.php  # Elementor widget generator
│   ├── MakeModule.php     # CRUD module generator
│   └── MakeSequence.php   # Database sequence generator
├── Config.php             # config.json reader helper
└── Console.php            # CLI router & command registry

To register your own custom CLI command, simply create a new class in cli/Commands/ and register it in cli/Console.php:

protected array $commands = [
  'init'           => Commands\Init::class,
  'build'          => Commands\Build::class,
  'docs'           => Commands\Docs::class,
  'make:module'    => Commands\MakeModule::class,
  'make:sequence'  => Commands\MakeSequence::class,
  'make:elementor' => Commands\MakeElementor::class,
  'my:command'     => Commands\MyCommand::class, // Custom command
];