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.
What Happens During init:
- Reads Settings: Retrieves
name,jsObject, andendpointsKeyPrefixfromconfig.json. - Batch Replacement: Scans all
.php,.js,.css,.txt,.json, and.stubfiles (ignoringvendor/,node_modules/, andcli/), replacing: - Text domains (
xe-plugin→<your-plugin-slug>) - Function prefixes (
_xe_plugin→_<your_plugin_slug>) - Class namespaces (
Xe_Plugin→<YourPlugin>) - Constant prefixes (
XE_PLUGIN_→<YOUR_PLUGIN_>) - JavaScript global objects (
xePlugin→<yourJsObject>) - Endpoint prefixes (
xep-→<yourPrefix>-) - Renames Main Plugin File: Renames
xe-plugin.phpto<your-plugin-slug>.php. - Regenerates Autoloader: Runs
composer dump-autoloadto 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.
Build Process Workflow:
- Cleans Previous Build: Removes any existing directory at
<build_path>/<plugin-slug>. - Copies Source Files: Recursively copies plugin files to the build directory.
- Applies Exclusions:
- Excluded Directories:
.git,.github,.vscode,node_modules,node_scripts,cli,stubs. - Excluded Files:
.gitignore,package.json,package-lock.json,composer.json,composer.lock,config.json,sftp-config.json,README.md,LICENSE.md,xe. - Excluded Extensions:
.psd,.settings. - Compiles Translations (
.pot): Automatically runswp i18n make-potusing WP-CLI to scan the build files and generate a new.pottranslation file in thelanguages/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:
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.