#!/usr/bin/env php add($cmd->toSymfony()); // If it's a generator, also register module-specific versions if (in_array($cmd->getName(), $generators, true)) { $modulesDir = getcwd() . '/modules'; if (is_dir($modulesDir)) { foreach (scandir($modulesDir) as $module) { if ($module === '.' || $module === '..' || !is_dir($modulesDir . '/' . $module)) { continue; } // Create a module-specific command name: create:shop:controller $moduleCmdName = str_replace('create:', 'create:' . strtolower($module) . ':', $cmd->getName()); // We need a fresh instance for each command name to avoid overwriting Symfony's command registry $moduleCmd = require $file; $moduleCmd->setName($moduleCmdName); $app->add($moduleCmd->toSymfony()); } } } } } } // Discover user commands in console/commands $userDir = getcwd() . '/console/commands'; if (is_dir($userDir)) { foreach (glob($userDir . '/*.php') as $file) { $cmd = require $file; if ($cmd instanceof \Phred\Console\Command) { $app->add($cmd->toSymfony()); } } } // Run $app->run(); }