Phred/bin/phred
Funky Waddle c845868f41 feat: implement M9 & M10 (CLI, Scaffolding, Security, JWT) and standardize middleware
- Implement full suite of 'phred' CLI generators and utility commands (M9).
- Refactor scaffolding logic to use external stubs in 'src/stubs'.
- Add security hardening via SecureHeaders, Csrf, and CORS middleware (M10).
- Implement JWT token issuance and validation service with lcobucci/jwt.
- Integrate 'getphred/flagpole' for feature flag support.
- Introduce abstract 'Middleware' base class for standardized PSR-15 implementation.
- Add robust driver validation to OrmServiceProvider.
- Fix JwtTokenService claims access and validation constraints.
- Update MILESTONES.md status.
2025-12-22 15:52:41 -06:00

81 lines
2.7 KiB
PHP

#!/usr/bin/env php
<?php
declare(strict_types=1);
namespace {
// Ensure composer autoload is available whether this is run from repo or installed project
$autoloadPaths = [
__DIR__ . '/../vendor/autoload.php', // project root vendor
__DIR__ . '/../../autoload.php', // vendor/bin scenario
];
$autoloaded = false;
foreach ($autoloadPaths as $path) {
if (is_file($path)) {
require $path;
$autoloaded = true;
break;
}
}
if (!$autoloaded) {
fwrite(STDERR, "Unable to locate Composer autoload.\n");
exit(1);
}
$app = new \Symfony\Component\Console\Application('Phred', '0.1');
// Discover core commands bundled with Phred (moved under src/commands)
$coreDir = dirname(__DIR__) . '/src/commands';
$generators = [
'create:controller',
'create:view',
'create:model',
'create:migration',
'create:seed',
'create:test'
];
if (is_dir($coreDir)) {
foreach (glob($coreDir . '/*.php') as $file) {
/** @var \Phred\Console\Command $cmd */
$cmd = require $file;
if ($cmd instanceof \Phred\Console\Command) {
$app->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:blog: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();
}