Skip to content

Project Initialization & Build Commands

This guide covers the project setup and deployment commands provided by php xe.


php xe init

The init command configures the boilerplate for your project by reading config.json and performing deep string replacement across all relevant files.

php xe init

What Happens During init:

  1. Reads Settings: Retrieves name, jsObject, and endpointsKeyPrefix from config.json.
  2. Batch Replacement: Scans all .php, .js, .css, .txt, .json, and .stub files (ignoring vendor/, node_modules/, and cli/), replacing:
  3. Text domains (xe-plugin<your-plugin-slug>)
  4. Function prefixes (_xe_plugin_<your_plugin_slug>)
  5. Class namespaces (Xe_Plugin<YourPlugin>)
  6. Constant prefixes (XE_PLUGIN_<YOUR_PLUGIN_>)
  7. JavaScript global objects (xePlugin<yourJsObject>)
  8. Endpoint prefixes (xep-<yourPrefix>-)
  9. Renames Main Plugin File: Renames xe-plugin.php to <your-plugin-slug>.php.
  10. Regenerates Autoloader: Runs composer dump-autoload to ensure the autoloader reflects all updated namespaces.

php xe build

The build command produces a clean, production-ready copy of your plugin in the directory specified in config.json.

php xe build

Build Process Workflow:

  1. Cleans Previous Build: Removes any existing directory at <build_path>/<plugin-slug>.
  2. Copies Source Files: Recursively copies plugin files to the build directory.
  3. Applies Exclusions:
  4. Excluded Directories: .git, .github, .vscode, node_modules, node_scripts, cli, stubs.
  5. Excluded Files: .gitignore, package.json, package-lock.json, composer.json, composer.lock, config.json, sftp-config.json, README.md, LICENSE.md, xe.
  6. Excluded Extensions: .psd, .settings.
  7. Compiles Translations (.pot): Automatically runs wp i18n make-pot using WP-CLI to scan the build files and generate a new .pot translation file in the languages/ folder.

[!NOTE] The POT generation step requires WP-CLI to be available in your system's PATH.


php xe docs

Deploys your documentation directly to GitHub Pages:

php xe docs

Runs mkdocs gh-deploy --force to compile the Markdown files in docs/ and deploy them to the gh-pages branch on your remote GitHub repository.