Skip to content

Custom Commands & Troubleshooting

Totoglu\Console\Support\FeatureDiscoverer automatically discovers custom Symfony Console commands in two ways:

  1. Module Auto-Discovery: Place *Command.php files inside site/modules/<Module>/commands/ (registered under the module’s Commands namespace).
  2. Composer Package Discovery: Declare command class names inside your package’s composer.json under extra.processwire-console.commands:
composer.json
{
"extra": {
"processwire-console": {
"commands": [
"Vendor\\Package\\Commands\\SyncCatalogCommand"
]
}
}
}

Use Totoglu\Console\Traits\InteractWithProcessWire to access the booted ProcessWire instance cleanly and support --dry-run and --json output:

site/modules/MyModule/commands/CatalogStatusCommand.php
<?php
declare(strict_types=1);
namespace Totoglu\MyModule\Commands;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Totoglu\Console\Traits\InteractWithProcessWire;
final class CatalogStatusCommand extends Command
{
use InteractWithProcessWire;
protected function configure(): void
{
$this
->setName('catalog:status')
->setDescription('Inspect published catalog item counts.')
->addOption('json', null, InputOption::VALUE_NONE, 'Output structured JSON.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$count = $this->wire()->pages->count('template=yacht');
if ($input->getOption('json')) {
$output->writeln(json_encode(['yachts' => $count], JSON_THROW_ON_ERROR));
return Command::SUCCESS;
}
$output->writeln("Published yachts: {$count}");
return Command::SUCCESS;
}
}

vendor/bin/wire Cannot Locate ProcessWire Root

Section titled “vendor/bin/wire Cannot Locate ProcessWire Root”
  • Run php vendor/bin/wire from your ProcessWire project root (the directory containing index.php and site/config.php).

Module Commands Do Not Appear in wire list

Section titled “Module Commands Do Not Appear in wire list”
  • Confirm the module is installed in ProcessWire (php vendor/bin/wire module:list --site --json) and that its commands/*Command.php namespace is registered in __construct().

queue:work Exits Immediately or Skips Jobs

Section titled “queue:work Exits Immediately or Skips Jobs”
  • Verify queue_jobs exists by running php vendor/bin/wire queue:table --json, and check failed jobs via php vendor/bin/wire queue:failed --json.

Next steps