Repository navigation
Internals Bootstrap Cli Handler
Framework Internals · Subsystem overview · Developer guide
Source: bootstrap/cli/handler.php · Snapshot 8411f4287706.
Bootstrap scripts wire globals, constants and collaborators in a defined order. These files are executable entry points rather than a reusable class API.
use cli\CLIHandler;
use cli\commands\ClearCommand;
use cli\commands\HelloCommand;
use cli\commands\InstallCommand;
use cli\commands\PackageManagerCommand;
use cli\commands\RoutesCommand;
use cli\commands\VersionCommand;The script below is executed by its caller. Constants, registered callbacks, global assignments, guards, included files and their order are preserved here. Unlike class methods, entry-point execution can start the CLI loop, route a request, emit output, or terminate the process.
<?php
ini_set('max_execution_time', 0);
global $routerManager;
global $loader;
use cli\CLIHandler;
use cli\commands\ClearCommand;
use cli\commands\HelloCommand;
use cli\commands\InstallCommand;
use cli\commands\PackageManagerCommand;
use cli\commands\RoutesCommand;
use cli\commands\VersionCommand;
global $cliHandler;
$cliHandler = new CLIHandler();
$_SERVER['REQUEST_URI'] = '/CLI/';
$cliHandler->addCommand(new InstallCommand());
if (DB_TYPE !== '') {
$cliHandler->addCommand(new ClearCommand());
$cliHandler->addCommand(new VersionCommand());
$cliHandler->addCommand(new HelloCommand());
$cliHandler->addCommand(new PackageManagerCommand());
$loader->CLIHandler = $cliHandler;
$rc = new RoutesCommand();
$rc->addRoutes($routerManager->getRoutes());
$cliHandler->addCommand($rc);
}
$argv = $_SERVER['argv'] ?? [];
array_shift($argv);
$firstCommand = $argv ? ['cmd' => array_shift($argv), 'args' => $argv] : null;
while (true) {
if ($firstCommand !== null) {
$cmd = $firstCommand['cmd'];
$args = $firstCommand['args'];
$firstCommand = null;
} else {
$input = readline("awt> ");
if ($input === false) break;
if (!$input) continue;
try {
$parts = $cliHandler->parseInput($input);
} catch (\InvalidArgumentException $exception) {
echo $exception->getMessage() . PHP_EOL;
continue;
}
if ($parts === []) continue;
$cmd = array_shift($parts);
$args = $parts;
}
if ($cmd === 'help') {
$cliHandler->help($args[0] ?? null);
continue;
}
if ($cmd === 'clear') {
echo "\033[2J\033[;H";
continue;
}
$cliHandler->execute($cmd, $args);
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes