> For the complete documentation index, see [llms.txt](https://quantumphp.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://quantumphp.gitbook.io/docs/packages/app/adapters.md).

# Adapters

Quantum ships two built-in app adapters: `web` and `console`.

Both satisfy the same `start(): ?int` contract, but they boot different runtime services and handle different entry-point work.

## Web adapter

Use the web adapter for HTTP traffic.

```php
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
* initializes the debugger store
* 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:

* `OPTIONS` requests short-circuit to `204 No Content`
* missing routes return a not-found response instead of throwing
* view cache is consulted before route dispatch when `ViewCache` is enabled
* CORS headers are loaded from `config/cors` on 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.

```php
use Quantum\App\Enums\AppType;
use Quantum\App\Factories\AppFactory;

$app = AppFactory::create(AppType::CONSOLE, __DIR__);
exit($app->start() ?? 0);
```

### What it does

The console adapter:

* creates Symfony `ArgvInput` and `ConsoleOutput`
* loads helpers for every command
* loads environment, app config, and error handling for all commands except `core:env`
* marks the shared `Environment` instance mutable for non-`core:env` commands
* creates the Symfony application using `app.name` and `app.version`
* registers framework and app command classes
* validates that the requested command exists before running

### 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://quantumphp.gitbook.io/docs/packages/app/adapters.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
