Skip to content

Internals CLI

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

CLI internals

Framework Internals · Developer guide

CLIHandler stores commands keyed by getCommand(), replacing duplicate names. parseInput handles quoting/escapes and empty arguments without shell expansion; malformed quoting or incomplete escapes throws InvalidArgumentException. execute invokes the command and prints result() if nonempty. Help derives argument descriptions and the first help line; no command is a separate subprocess.

bootstrap/cli/handler.php creates a new handler, sets REQUEST_URI to /CLI/, registers install, then configured-state maintenance/package/routes commands. It optionally consumes argv for one initial command and enters readline indefinitely until EOF. help/clear are handled by the loop. The command result is text; there is no general exit-code or noninteractive mode policy.

InstallCommand requires seven arguments and catches InvalidArgumentException/RuntimeException. PackageManagerCommand accepts install/update/remove/enable/disable/list, builds a ZIP pipeline, uses curl only for URL sources, catches Throwable and cleans its temporary copied archive. RoutesCommand prints a table without constructing lazy controllers. ClearCommand clears screen rather than caches; VersionCommand reports the framework version.

Package APIs can call addCommand(), but installed bootstrap replaces the handler after their execution, losing those registrations. Manage and PackageList helper classes are currently empty shells; they have no additional functional API. Command arguments must be validated by each command; the CLIHandler itself only dispatches them.

Component reference

Clone this wiki locally