App
The App package is Quantum's bootstrap and runtime entry point.
Use it when you need to start either a web request lifecycle or a console command lifecycle from a project base directory.
What the package provides
AppFactoryfor creating the runtime entry pointAppas the adapter-backed application objectAppContextfor base-directory and DI-backed shared runtime access- built-in
webandconsoleadapters - bootstrap stages for helpers, environment, config, HTTP, debugger, modules, and error handling
- path and utility helpers such as
base_dir(),modules_dir(),slugify(), anduuid_random()
Quick start
Boot a web app
use Quantum\App\Factories\AppFactory;
use Quantum\App\Enums\AppType;
$app = AppFactory::create(AppType::WEB, __DIR__);
$app->start();
Boot a console app
use Quantum\App\Factories\AppFactory;
use Quantum\App\Enums\AppType;
$app = AppFactory::create(AppType::CONSOLE, __DIR__);
$exitCode = $app->start();
When to use it
Use the App package when you are wiring framework startup itself:
- front controllers such as
public/index.php - CLI entry points such as
qt - tests or tools that need a full Quantum app instance
Most application code should use downstream packages like Router, Http, View, or Console instead of talking to App internals directly.
Important behavior
AppFactory::create() caches one App instance per app type.
Practical effect:
- the first
webapp created in a process is reused for laterwebcalls - the first
consoleapp created in a process is reused for laterconsolecalls - changing the base directory in a later call does not create a new instance for the same type
If you need a fresh runtime for the same type, call AppFactory::destroy($type) before creating it again.