Skip to content

Project Commands

Project-specific commands manage individual WordPress project development, PHP versions, and build processes.

Command Format

bash
wdg <project-name> <command> [options]

PHP Version Management

Check PHP Version

bash
wdg my-site php

Output:

Project: my-site
PHP Version: 8.2
Container: wdg-wp-my-site
Status: Running

Set PHP Version

bash
wdg my-site php set 8.3

What happens:

  1. Stops project container
  2. Rebuilds with new PHP version
  3. Preserves database and files
  4. Restarts container
  5. Updates project config

Available versions:

  • 8.0 - Legacy support
  • 8.1 - Stable
  • 8.2 - Default
  • 8.3 - Latest

💡 TIP

Changing PHP versions rebuilds the container but keeps all data intact including database, uploads, and configurations.

List Available PHP Versions

bash
wdg my-site php available

Output:

Available PHP Versions:
  8.0 - PHP 8.0.x (Legacy)
  8.1 - PHP 8.1.x (Stable)
  8.2 - PHP 8.2.x (Default) ✓ Current
  8.3 - PHP 8.3.x (Latest)

Development Mode

Start Development Server

bash
wdg my-site dev

What it does:

  1. Detects package.json in theme or app directory
  2. Runs npm start or npm run dev
  3. Watches for file changes
  4. Auto-rebuilds assets
  5. Enables hot module replacement (if configured)

Priority order:

  1. Theme directory (wp-content/themes/project-name/)
  2. App directory (wp-content/plugins/wikit-app/)
  3. First found package.json in repositories

Example output:

Starting development mode for my-site...
Found package.json: wp-content/themes/my-site/package.json
Running: npm start

> my-site-theme@1.0.0 start
> webpack serve --mode development

webpack 5.88.0 compiled with 0 warnings in 2453 ms
Development server running at: http://localhost:3000
Watching for changes...

Stop Development Mode

bash
# Press Ctrl+C in the terminal where dev server is running
# Or kill the process:
pkill -f "npm start"

Build Commands

Production Build

bash
wdg my-site build

What it does:

  1. Finds all package.json files in project
  2. Runs npm run build in each location
  3. Minifies and optimizes assets
  4. Generates production-ready bundles
  5. Reports build status

Example output:

Building production assets for my-site...

[1/2] Building theme...
Location: wp-content/themes/my-site
Running: npm run build
✓ Theme built successfully (12.3s)
Output: dist/

[2/2] Building app...
Location: wp-content/plugins/wikit-app
Running: npm run build
✓ App built successfully (8.7s)
Output: build/

Build complete! Total time: 21.0s

Development Build

bash
wdg my-site build --dev

Builds with development flags:

  • Unminified code
  • Source maps enabled
  • Debug mode on

Watch Mode Build

bash
wdg my-site build --watch

Rebuilds automatically on file changes.

Repository Commands

Add Repository

bash
wdg my-site repo add <git-url> [branch]

Examples:

bash
# Add repository (default branch)
wdg my-site repo add https://github.com/client/custom-plugin

# Add specific branch
wdg my-site repo add https://github.com/client/theme develop

# Add with SSH
wdg my-site repo add git@github.com:client/plugin.git

What it does:

  1. Clones repository to project's repositories/ directory
  2. Installs git hooks for auto-indexing
  3. Indexes code for AI search
  4. Updates project configuration

List Repositories

bash
wdg my-site repo list

Output:

Repositories for my-site:

my-site (wp-content)
  Path: repositories/my-site
  Branch: main
  Status: ✓ Clean
  Last commit: abc123 (2 hours ago)
  Indexed: Yes (1,450 vectors)

custom-plugin (plugin)
  Path: repositories/custom-plugin
  Branch: develop
  Status: ⚠ Modified (3 files)
  Last commit: def456 (1 day ago)
  Indexed: Yes (234 vectors)

Update Repository

bash
wdg my-site repo pull <repo-name>

Example:

bash
wdg my-site repo pull custom-plugin

What it does:

  1. Pulls latest changes from remote
  2. Shows commit history
  3. Re-indexes if code changed
  4. Updates vector database

Sync All Repositories

bash
wdg my-site repo sync

Pulls latest changes from all repositories in project.

Repository Status

bash
wdg my-site repo status [repo-name]

Shows git status for project repositories.

Container Management

Restart Container

bash
wdg restart my-site

Stops and starts the WordPress container.

Rebuild Container

bash
wdg rebuild my-site

Rebuilds Docker image and container (useful after config changes).

Container Logs

bash
wdg logs my-site [--follow]

Examples:

bash
# View recent logs
wdg logs my-site

# Follow logs in real-time
wdg logs my-site --follow

# Last 100 lines
wdg logs my-site --tail 100

Container Shell Access

bash
wdg shell my-site

Opens bash shell inside WordPress container:

bash
# You're now inside the container
www-data@my-site:/var/www/html$ wp plugin list
www-data@my-site:/var/www/html$ php -v
www-data@my-site:/var/www/html$ exit

Database Commands

Export Database

bash
wdg db export my-site [filename]

Examples:

bash
# Auto-generated filename
wdg db export my-site

# Custom filename
wdg db export my-site backup-$(date +%Y%m%d).sql

# With compression
wdg db export my-site | gzip > backup.sql.gz

Import Database

bash
wdg db import my-site <sql-file>

Example:

bash
wdg db import my-site production-db.sql

⚠️ WARNING

This will replace all existing data in the project database!

Database Reset

bash
wdg db reset my-site

Resets database to fresh WordPress installation.

Search & Replace

bash
wdg db search-replace my-site <search> <replace>

Examples:

bash
# Change domain
wdg db search-replace my-site \
    "oldsite.com" \
    "newsite.com"

# Update URLs
wdg db search-replace my-site \
    "http://localhost" \
    "https://production.com"

WordPress CLI

Run WP-CLI Commands

bash
wdg wp my-site <wp-cli-command>

Examples:

bash
# List plugins
wdg wp my-site plugin list

# Activate plugin
wdg wp my-site plugin activate custom-plugin

# Create user
wdg wp my-site user create john john@example.com \
    --role=administrator \
    --user_pass=password123

# Clear cache
wdg wp my-site cache flush

# Run cron
wdg wp my-site cron event run --all

# Export content
wdg wp my-site export --dir=exports/

# Import content
wdg wp my-site import exports/data.xml --authors=create

# Database operations
wdg wp my-site db query "SELECT * FROM wp_users"
wdg wp my-site db optimize
wdg wp my-site db check

Indexing Commands

Index Project

bash
wdg index my-site [options]

Options:

  • --force - Re-index all files
  • --update - Pull repo updates first
  • --types <types> - Index only specific file types

Examples:

bash
# Full index
wdg index my-site

# Force re-index
wdg index my-site --force

# Index only PHP
wdg index my-site --types php

# Update and index
wdg index my-site --update

Index Status

bash
wdg status my-site

Output:

Project: my-site
Status: Running
URL: https://my-site.localhost:8443
PHP: 8.2
Database: wp_my_site (45.2 MB)

Indexing Status:
  Collection: project_my_site
  Vectors: 1,450
  Last indexed: 2024-10-14 10:30:00
  Auto-indexing: Enabled

Repositories:
  ✓ my-site (main) - 1,200 vectors
  ✓ custom-plugin (develop) - 250 vectors

Configuration Commands

View Project Config

bash
wdg config show my-site

Output:

json
{
  "name": "my-site",
  "created": "2024-10-14T10:30:00Z",
  "php_version": "8.2",
  "domain": "my-site.localhost",
  "ssl": true,
  "database": {
    "name": "wp_my_site",
    "user": "wordpress",
    "host": "mysql"
  },
  "repositories": [...],
  "indexing": {
    "enabled": true,
    "auto_index": true,
    "collection": "project_my_site"
  }
}

Update Project Config

bash
wdg config set my-site <key> <value>

Examples:

bash
# Enable debug mode
wdg config set my-site wp_debug true

# Set memory limit
wdg config set my-site php_memory_limit 512M

# Set timezone
wdg config set my-site timezone America/New_York

Environment Commands

Set Environment Variables

bash
wdg env set my-site <key> <value>

Examples:

bash
# Set custom environment variable
wdg env set my-site API_KEY abc123

# Enable debugging
wdg env set my-site WP_DEBUG true

# Set custom domain
wdg env set my-site WP_HOME https://my-custom-domain.test

List Environment Variables

bash
wdg env list my-site

Performance Commands

Check Performance

bash
wdg perf my-site

Output:

Performance Metrics for my-site:

Container Resources:
  CPU: 12.5%
  Memory: 450 MB / 2 GB
  Disk I/O: 2.3 MB/s

WordPress Performance:
  Database queries: 42 per page
  Page load time: 1.2s
  Memory usage: 45 MB peak

Recommendations:
  ✓ PHP-FPM configured correctly
  ⚠ Consider object caching
  ✓ Database indexes optimal

Optimize Database

bash
wdg optimize my-site

Optimizes database tables and clears expired transients.

Backup Commands

Create Backup

bash
wdg backup my-site [--full]

Options:

  • Default: Database only
  • --full: Database + files

Output:

Creating backup for my-site...
✓ Database exported: backups/my-site-20241014.sql
✓ Files archived: backups/my-site-files-20241014.tar.gz
Backup complete: backups/my-site-20241014-full.tar.gz (145 MB)

Restore from Backup

bash
wdg restore my-site <backup-file>

Common Workflows

Daily Development

bash
# Start project and dev server
wdg start my-site
wdg my-site dev

# Make changes...
# Commit triggers auto-indexing

# Stop when done
# Ctrl+C to stop dev server
wdg stop my-site

Switching PHP Versions

bash
# Check current version
wdg my-site php
# Output: 8.2

# Change to 8.3
wdg my-site php set 8.3
# Container rebuilds automatically

# Verify
wdg my-site php
# Output: 8.3

Production Build Process

bash
# 1. Build assets
wdg my-site build

# 2. Export database
wdg db export my-site production.sql

# 3. Search/replace domains
wdg db search-replace my-site \
    "my-site.localhost:8443" \
    "production-domain.com"

# 4. Create full backup
wdg backup my-site --full

# 5. Deploy (manual or automated)

See Also:

Released under the MIT License.