2026-02-14 23:27:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
|
|
|
|
|
|
use Atlas\Router\Router;
|
|
|
|
|
use Atlas\Config\Config;
|
2026-02-15 05:43:17 +00:00
|
|
|
use Atlas\Commands\ListRoutesCommand;
|
|
|
|
|
use Atlas\Commands\TestRouteCommand;
|
2026-02-14 23:27:55 +00:00
|
|
|
|
|
|
|
|
$command = $argv[1] ?? 'help';
|
|
|
|
|
|
|
|
|
|
$config = new Config([
|
|
|
|
|
'modules_path' => __DIR__ . '/src/Modules',
|
|
|
|
|
'routes_file' => 'routes.php'
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$router = new Router($config);
|
|
|
|
|
|
|
|
|
|
// Load routes from a central routes file if it exists, or provide a way to load them
|
|
|
|
|
// For this CLI tool, we might need a way to bootstrap the application's router.
|
|
|
|
|
// Usually, this would be part of a framework. For Atlas as a library, we provide
|
|
|
|
|
// the tool that can be integrated.
|
|
|
|
|
|
|
|
|
|
// In a real scenario, the user would point this tool to their router bootstrap file.
|
|
|
|
|
// For demonstration, let's assume we have a `bootstrap/router.php` that returns the Router.
|
|
|
|
|
|
|
|
|
|
$bootstrapFile = getcwd() . '/bootstrap/router.php';
|
|
|
|
|
if (file_exists($bootstrapFile)) {
|
|
|
|
|
$router = require $bootstrapFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch ($command) {
|
|
|
|
|
case 'route:list':
|
2026-02-15 05:43:17 +00:00
|
|
|
(new ListRoutesCommand())->execute($router, $argv);
|
2026-02-14 23:27:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'route:test':
|
2026-02-15 05:43:17 +00:00
|
|
|
(new TestRouteCommand())->execute($router, $argv);
|
2026-02-14 23:27:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
echo "Atlas Routing CLI" . PHP_EOL;
|
|
|
|
|
echo "Usage:" . PHP_EOL;
|
|
|
|
|
echo " php atlas route:list [--json]" . PHP_EOL;
|
|
|
|
|
echo " php atlas route:test <METHOD> <PATH> [--verbose]" . PHP_EOL;
|
|
|
|
|
break;
|
|
|
|
|
}
|