Troubleshooting

WP-CLI package issues and fixes.

Command Issues

"wp zylos" not found

Problem: WP-CLI doesn't recognize zylos namespace.

Cause: Plugin not active or commands not registered.

Fix: Verify plugin is active and WP-CLI detected:

wp plugin list
wp zylos list  # Should show available commands

Commands don't appear

Problem: wp zylos list shows empty list.

Cause: WP-CLI check failing or provider not booting.

Fix: Verify WP-CLI context in provider:

public function boot(): void
{
    if (!defined('WP_CLI') || !WP_CLI) {
        return; // WP-CLI not available
    }

    // Register commands
}

"Call to undefined function"

Problem: WordPress functions undefined in command.

Cause: Command runs before WordPress loads.

Fix: WPZylos commands run after WordPress load. Verify:

# Run with --debug to see loading order
wp zylos mycommand --debug

Output Issues

Table formatting broken

Problem: WP_CLI::print_table() output misaligned.

Cause: Unicode characters or very long values.

Fix: Truncate long values:

$data = array_map(function ($row) {
    $row['title'] = substr($row['title'], 0, 50);
    return $row;
}, $data);

WP_CLI\Utils\format_items('table', $data, ['id', 'title']);