Tooling & CLI
Tooling & CLI
Automation is a core pillar of our development workflow. We utilize WP-CLI alongside custom shell scripts to streamline environment setup, database management, and contribution workflows.
Prerequisites
To use the tools described below, ensure you have the following installed:
- WP-CLI: The command-line interface for WordPress.
- Composer: For managing PHP dependencies.
- Standard Unix utilities (
bash,grep,sed).
Core Automation Scripts
The repository includes a suite of scripts located in the /bin directory. These are designed to be run from the project root.
Environment Setup
Initializes a local development environment, installs core files, and configures the database.
# Set up a fresh development instance
./bin/setup.sh --site-url="wordpress.local" --db-name="wp_dev"
| Parameter | Type | Description |
| :--- | :--- | :--- |
| --site-url | string | The local development URL (e.g., wp.test). |
| --db-name | string | The name of the MySQL database to create/use. |
Database Sync
Synchronizes the local database with a staging or production snapshot (requires SSH access configured).
# Sync from staging to local
./bin/sync-db.sh staging
Custom WP-CLI Commands
We extend WP-CLI with project-specific commands to handle repetitive tasks. These are registered via the wp-cli.yml configuration.
wp contrib-tools
A utility command to help manage WordPress core and plugin contributions.
Usage:
wp contrib-tools <action> [options]
Actions:
init: Sets up a clean WordPress core checkout for patching.patch <issue-id>: Downloads and applies a patch from Trac or GitHub.test: Runs the PHPUnit test suite for the current component.
Example:
# Apply a patch for issue #54321
wp contrib-tools patch 54321
Quality Assurance & Linting
We use integrated CLI tools to maintain code standards before contributing upstream.
PHP CodeSniffer (WPCS)
Validates code against WordPress Coding Standards.
# Run linting on the entire project
composer lint
# Automatically fix fixable violations
composer format
Static Analysis (PHPStan)
Analyzes code for potential bugs without executing it.
# Run static analysis
composer analyze
Global Configuration
Configuration for these tools is managed via the following files in the root directory:
wp-cli.yml: Defines default parameters for WP-CLI and registers custom commands..phpcs.xml.dist: Ruleset for WordPress Coding Standards.phpstan.neon: Configuration for static analysis levels and ignored paths.
Note: These tools are intended for use in development environments. Ensure your
WP_CLI_CONFIG_PATHis correctly set if you are running these within Docker containers or virtualized environments.