Usage

This guide covers using the WPZylos CLI Devtool commands.

Quick Start

# Install as a dev dependency
composer require --dev KYNetCode/wpzylos-cli-devtool

# List all commands
vendor/bin/wpzylos list

# Get help for a specific command
vendor/bin/wpzylos make:controller --help

Context Detection

All commands automatically detect your plugin context from the .plugin-config.json manifest:

  • Namespace - Used as the root namespace for generated classes
  • Slug - Used for text domains, hook prefixes, and REST routes
  • Prefix - Used for database prefixes and hook names

To override, use --path to point to a different plugin root.


Foundation Commands

# Service class
vendor/bin/wpzylos make:service PaymentService
vendor/bin/wpzylos make:service Billing/InvoiceService

# Service provider
vendor/bin/wpzylos make:provider AppServiceProvider

# Queued job
vendor/bin/wpzylos make:job ProcessPayment

# Trait
vendor/bin/wpzylos make:trait HasSlug

# Enum (string, int, or plain)
vendor/bin/wpzylos make:enum Status
vendor/bin/wpzylos make:enum Priority --int
vendor/bin/wpzylos make:enum Color --plain

# Exception
vendor/bin/wpzylos make:exception PaymentFailed
vendor/bin/wpzylos make:exception Api/RateLimitException --render

# Interface
vendor/bin/wpzylos make:interface PaymentGateway

Console Commands

# Custom CLI command
vendor/bin/wpzylos make:command PurgeCache

# WordPress cron/scheduled task
vendor/bin/wpzylos make:cron CleanupExpiredTokens
vendor/bin/wpzylos make:cron SyncInventory --recurrence=hourly

HTTP Commands

# Controller
vendor/bin/wpzylos make:controller ProductController --resource

# Middleware
vendor/bin/wpzylos make:middleware AuthMiddleware

# Form request
vendor/bin/wpzylos make:request StoreProductRequest

# WordPress REST API controller
vendor/bin/wpzylos make:rest OrderController --route=orders

# WordPress AJAX handler
vendor/bin/wpzylos make:ajax SearchProducts --public

# API resource transformer
vendor/bin/wpzylos make:resource UserResource

Database and Model Commands

# Migration
vendor/bin/wpzylos make:migration create_products_table --create=products

# Model
vendor/bin/wpzylos make:model Product

# Seeder
vendor/bin/wpzylos make:seeder ProductSeeder

# Factory (for testing)
vendor/bin/wpzylos make:factory OrderFactory --model=Order

# Observer
vendor/bin/wpzylos make:observer OrderObserver --model=Order

# Query Scope
vendor/bin/wpzylos make:scope ActiveScope

# Attribute Cast
vendor/bin/wpzylos make:cast JsonCast

Event Commands

vendor/bin/wpzylos make:event OrderPlaced
vendor/bin/wpzylos make:listener SendOrderNotification
vendor/bin/wpzylos make:subscriber OrderSubscriber

Mail and Notifications

# Mailable (uses wp_mail)
vendor/bin/wpzylos make:mail WelcomeEmail

# Multi-channel notification (mail + admin_notice)
vendor/bin/wpzylos make:notification OrderShipped

Validation and Authorization

# Validation rule (requires wpzylos-validation package)
vendor/bin/wpzylos make:rule Uppercase

# Authorization policy (uses current_user_can)
vendor/bin/wpzylos make:policy PostPolicy

Testing and Configuration

# Test class
vendor/bin/wpzylos make:test UserServiceTest
vendor/bin/wpzylos make:test Feature/OrderTest --feature

# Configuration file
vendor/bin/wpzylos make:config cache

WordPress Commands

# Custom Post Type
vendor/bin/wpzylos make:posttype Product

# Taxonomy
vendor/bin/wpzylos make:taxonomy ProductCategory

# Metabox
vendor/bin/wpzylos make:metabox ProductDetails

# Admin Menu
vendor/bin/wpzylos make:menu SettingsMenu

# Settings Page
vendor/bin/wpzylos make:settings GeneralSettings

# Widget
vendor/bin/wpzylos make:widget RecentProducts

# Shortcode
vendor/bin/wpzylos make:shortcode Gallery --tag=photo_gallery

# Gutenberg Block (folder-based)
vendor/bin/wpzylos make:block HeroBanner --title="Hero Banner" --category=design

# Admin Columns
vendor/bin/wpzylos make:columns OrderColumns --post-type=shop_order

# Action Hook
vendor/bin/wpzylos make:action SendWelcomeEmail --hook=user_register

# Filter Hook
vendor/bin/wpzylos make:filter AddReadingTime --hook=the_content

Common Options

All make commands support:

OptionDescription
--pathPlugin root path (auto-detected from working dir)
--forceOverwrite existing files
--dry-runPreview generated code without writing to disk

Dry Run Preview

Use --dry-run to preview what will be generated:

vendor/bin/wpzylos make:service PaymentService --dry-run

This displays the generated file path and code without creating the file.


Batch Generation

Create all files for a feature at once:

vendor/bin/wpzylos make:model Product
vendor/bin/wpzylos make:migration create_products_table --create=products
vendor/bin/wpzylos make:controller ProductController --resource
vendor/bin/wpzylos make:request StoreProductRequest
vendor/bin/wpzylos make:rest ProductRestController --route=products
vendor/bin/wpzylos make:factory ProductFactory --model=Product
vendor/bin/wpzylos make:observer ProductObserver --model=Product
vendor/bin/wpzylos make:policy ProductPolicy
vendor/bin/wpzylos make:test ProductServiceTest