App Adapters
Quantum ships two built-in app adapters: web and console.
Both follow the same lifecycle, boot() and then start(): ?int (see Contracts), but they boot different runtime services and handle different entry-point work.
Web adapter
Use the web adapter for HTTP traffic.
use Quantum\App\Enums\AppType;
use Quantum\App\Factories\AppFactory;
$app = AppFactory::create(AppType::WEB, __DIR__);
$app->start();What it does
The web adapter:
- loads framework, app, and module helpers
- loads environment and app config
- installs the error handler
- registers request and response objects in DI
- loads module routes into a
RouteCollection - matches the current request and dispatches it through middleware
Web response behavior
A few web behaviors are worth planning for:
OPTIONSrequests short-circuit to204 No Content- missing routes return a not-found response instead of throwing
- view cache is consulted before route dispatch when
ViewCacheis enabled - CORS headers are loaded from
config/corson first response send - request state is flushed after the response is sent
Console adapter
Use the console adapter for the qt entry point or any custom CLI bootstrap.
use Quantum\App\Enums\AppType;
use Quantum\App\Factories\AppFactory;
$app = AppFactory::create(AppType::CONSOLE, __DIR__);
exit($app->start() ?? 0);What it does
Every php qt <command> goes the same way: the adapter boots the project (helpers, the framework commands, .env, app config, error handler, then your commands from shared/Commands), checks that the requested command exists, runs it through Symfony Console, and returns its exit code.
Without a working .env, only a few commands such as core:env can run; see Commands without a working environment.
The adapter does not make the environment writable. A command that changes .env through environment()->updateRow() calls setMutable(true) first, as core:key does.
The stages behind these steps are listed in Architecture.
Command registration contract
App commands are discovered only from shared/Commands.
Framework commands are discovered from the framework's own Console/Commands directory.
Discovered classes are instantiated directly, so constructor-injected command dependencies are not part of this adapter's command-loading model.
Unsupported adapter types
AppFactory::create() accepts only:
AppType::WEB(web)AppType::CONSOLE(console)
Any other type fails fast with an app exception.
