> 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/config/overview.md).

# Overview

The Config package gives Quantum one shared in-memory configuration store.

Use it when you want to load PHP config files through `Loader`, read values with dot notation, and override values at runtime.

## What this package does

* loads config arrays from PHP files through `Quantum\Loader\Setup`
* stores values in one dot-accessible container
* supports two loading modes: `load()` for the root store and `import()` for named config sections
* exposes a DI-backed `config()` helper for shared access

## Most applications use `import()`

Quantum's package-level config files are usually imported under their file name:

```php
use Quantum\Loader\Setup;

config()->import(new Setup('config', 'app'));
config()->import(new Setup('config', 'database'));

$appName = config()->get('app.name');
$defaultDatabase = config()->get('database.default');
```

This is the normal shape used across the framework: each imported file becomes a top-level key such as `app`, `database`, or `mailer`.

## When `load()` is a better fit

Use `load()` when you want one config file to become the entire root store instead of being nested under its filename.

```php
use Quantum\Config\Config;
use Quantum\Loader\Setup;

$config = new Config();
$config->load(new Setup('config', 'app'));

$debug = $config->get('debug');
```

With `load()`, keys come from the file directly. With `import()`, the same file would be read under `app.debug`.

## Package shape

* `Quantum\Config\Config` manages the in-memory store
* `Quantum\Config\Contracts\ConfigInterface` defines the public API
* `Quantum\Config\Helpers\config.php` exposes the shared helper
* `Quantum\Config\Exceptions\ConfigException` reports import-name collisions

## Important runtime constraints

* `config()` returns one shared `Config` instance from DI, so runtime changes are shared for the current container lifecycle.
* `load()` is one-shot. After the first successful load, later `load()` calls do nothing until you `flush()`.
* `import()` always stores loaded data under the `Setup` filename.
* Import collisions are only guarded by that top-level filename. Re-importing the same truthy filename throws a `ConfigException`.
* For predictable imports, use a real non-empty filename in `Setup`.


---

# 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/config/overview.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.
