# ExtensionRegistry

> Holds the collectors and panels an application registered, ordered by the shared registration policy.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › ExtensionRegistry

| final readonly class | `Yii3\Debug\ExtensionRegistry` |
| --- | --- |
| Source | [`src/ExtensionRegistry.php`](https://github.com/yii3/debug/blob/main/src/ExtensionRegistry.php#L27) |

Holds the collectors and panels an application registered, ordered by the shared registration policy.

Panels reach [`ExtensionRegistry::panels()`](/docs/extensions/yii3-debug/reference/extensionregistry/index.md#method-panels) in the order [`PanelRegistry`](https://github.com/php-forge/debug-core/blob/b70459f033a1d7a1c5edf7951029aad2061986dd/src/Registration/PanelRegistry.php) computes: built-in IDs keep their
registration order and every extension follows by position, then by effective title, then by ID.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Validates the registration keys, applies the configured metadata, and computes the navigation order. | `ExtensionRegistry` |
| [`collectors()`](#method-collectors) | Returns the collectors the application enabled. | `ExtensionRegistry` |
| [`collectorsWithBuiltIn()`](#method-collectorsWithBuiltIn) | Returns the built-in collector first, unless the application explicitly registered an override with the same ID. | `ExtensionRegistry` |
| [`collectorsWithBuiltIns()`](#method-collectorsWithBuiltIns) | Returns built-in collectors first, replacing each one with an explicitly registered collector of the same ID. | `ExtensionRegistry` |
| [`create()`](#method-create) static | Creates a registry from explicitly enabled collectors and panels. | `ExtensionRegistry` |
| [`disabled()`](#method-disabled) | Returns the IDs the configuration removed, which a host tells apart from an ID it never knew. | `ExtensionRegistry` |
| [`fromParams()`](#method-fromParams) static | Creates a registry from the `collectors` and `panels` entries of the application configuration. | `ExtensionRegistry` |
| [`panels()`](#method-panels) | Returns the panels the application enabled. | `ExtensionRegistry` |
| [`panelsWithBuiltIn()`](#method-panelsWithBuiltIn) | Returns the built-in panel first, unless the application explicitly registered an override with the same ID. | `ExtensionRegistry` |
| [`panelsWithBuiltIns()`](#method-panelsWithBuiltIns) | Returns built-in panels first, replacing each one with an explicitly registered panel of the same ID. | `ExtensionRegistry` |
| [`withCollector()`](#method-withCollector) | Returns a copy with one more enabled collector appended. | `ExtensionRegistry` |
| [`withPanel()`](#method-withPanel) | Returns a copy with one more enabled panel appended. | `ExtensionRegistry` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(iterable<array-key, PHPForge\Debug\CollectorInterface> $collectors = [], iterable<array-key, Yii3\Debug\Panel\ExtensionPanelInterface|PHPForge\Debug\Panel> $panels = [], iterable<string, PHPForge\Debug\Registration\PanelOverride> $overrides = [], iterable<string> $disabled = [])
```

Validates the registration keys, applies the configured metadata, and computes the navigation order.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$collectors` | `iterable<array-key,` [`CollectorInterface`](https://github.com/php-forge/debug/blob/e4fbb8c3238a4d011ceef5e0094344abd50deaf4/src/CollectorInterface.php)`>` | Enabled collectors in capture order. |
| `$panels` | `iterable<array-key,` [`Yii3\Debug\Panel\ExtensionPanelInterface`](/docs/extensions/yii3-debug/reference/panel/extensionpanelinterface/index.md)`\|PHPForge\Debug\Panel>` | Enabled panels, in registration order. |
| `$overrides` | `iterable<string, PHPForge\Debug\Registration\PanelOverride>` | Application overrides indexed by panel ID. |
| `$disabled` | `iterable<string>` | IDs the configuration disabled, so the host tells them from missing ones. |

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): when an ID is empty or duplicated, a string key does not match the ID the entry declares, or an override renames a panel rendering its own title and icon.

### collectors() <span id="method-collectors"></span>

```php
public function collectors(): list<PHPForge\Debug\CollectorInterface>
```

Returns the collectors the application enabled.

**Returns**

`list<`[`CollectorInterface`](https://github.com/php-forge/debug/blob/e4fbb8c3238a4d011ceef5e0094344abd50deaf4/src/CollectorInterface.php)`>`: Enabled collectors in capture order.

### collectorsWithBuiltIn() <span id="method-collectorsWithBuiltIn"></span>

```php
public function collectorsWithBuiltIn(PHPForge\Debug\CollectorInterface $builtIn): list<PHPForge\Debug\CollectorInterface>
```

Returns the built-in collector first, unless the application explicitly registered an override with the same ID.

A built-in whose ID the configuration disabled is dropped instead of placed first.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$builtIn` | [`CollectorInterface`](https://github.com/php-forge/debug/blob/e4fbb8c3238a4d011ceef5e0094344abd50deaf4/src/CollectorInterface.php) | Built-in collector to place first. |

**Returns**

`list<`[`CollectorInterface`](https://github.com/php-forge/debug/blob/e4fbb8c3238a4d011ceef5e0094344abd50deaf4/src/CollectorInterface.php)`>`: Built-in and enabled collectors in capture order.

### collectorsWithBuiltIns() <span id="method-collectorsWithBuiltIns"></span>

```php
public function collectorsWithBuiltIns(iterable<PHPForge\Debug\CollectorInterface> $builtIns): list<PHPForge\Debug\CollectorInterface>
```

Returns built-in collectors first, replacing each one with an explicitly registered collector of the same ID.

A built-in whose ID the configuration disabled is dropped instead of placed first.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$builtIns` | `iterable<`[`CollectorInterface`](https://github.com/php-forge/debug/blob/e4fbb8c3238a4d011ceef5e0094344abd50deaf4/src/CollectorInterface.php)`>` | Built-in collectors in capture order. |

**Returns**

`list<`[`CollectorInterface`](https://github.com/php-forge/debug/blob/e4fbb8c3238a4d011ceef5e0094344abd50deaf4/src/CollectorInterface.php)`>`: Built-in and enabled collectors in capture order.

### create() <span id="method-create"></span>

```php
public static function create(iterable<array-key, PHPForge\Debug\CollectorInterface> $collectors = [], iterable<array-key, Yii3\Debug\Panel\ExtensionPanelInterface|PHPForge\Debug\Panel> $panels = [], iterable<string, PHPForge\Debug\Registration\PanelOverride> $overrides = [], iterable<string> $disabled = []): self
```

Creates a registry from explicitly enabled collectors and panels.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$collectors` | `iterable<array-key,` [`CollectorInterface`](https://github.com/php-forge/debug/blob/e4fbb8c3238a4d011ceef5e0094344abd50deaf4/src/CollectorInterface.php)`>` | Enabled collectors in capture order. |
| `$panels` | `iterable<array-key,` [`Yii3\Debug\Panel\ExtensionPanelInterface`](/docs/extensions/yii3-debug/reference/panel/extensionpanelinterface/index.md)`\|PHPForge\Debug\Panel>` | Enabled panels, in registration order. |
| `$overrides` | `iterable<string, PHPForge\Debug\Registration\PanelOverride>` | Application overrides indexed by panel ID. |
| `$disabled` | `iterable<string>` | IDs the configuration disabled. |

**Returns**

`self`: Registry holding the enabled collectors and panels.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): when the registration is invalid.

### disabled() <span id="method-disabled"></span>

```php
public function disabled(): list<string>
```

Returns the IDs the configuration removed, which a host tells apart from an ID it never knew.

**Returns**

`list<string>`: Disabled IDs, sorted alphabetically.

### fromParams() <span id="method-fromParams"></span>

```php
public static function fromParams(iterable<array-key, mixed> $collectors, iterable<array-key, mixed> $panels, Psr\Container\ContainerInterface $container): self
```

Creates a registry from the `collectors` and `panels` entries of the application configuration.

Every entry is a class string, or an array declaring a `class` string plus options. A collector accepts the
`enabled` option alone; a panel accepts the keys [`PanelOverride::KEYS`](https://github.com/php-forge/debug-core/blob/53c259241281d3275cd5cbfa64f08eb986d6bce3/src/Registration/PanelOverride.php#L29). An entry the configuration
disabled is reported by [`ExtensionRegistry::disabled()`](/docs/extensions/yii3-debug/reference/extensionregistry/index.md#method-disabled) and its class is never resolved.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$collectors` | `iterable<array-key, mixed>` | Collector entries indexed by configuration ID. |
| `$panels` | `iterable<array-key, mixed>` | Panel entries indexed by configuration ID. |
| `$container` | `Psr\Container\ContainerInterface` | Container the enabled classes are resolved from. |

**Returns**

`self`: Registry holding the enabled collectors and panels.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): when an entry, an option, or the resulting registration is invalid.

### panels() <span id="method-panels"></span>

```php
public function panels(): list<Yii3\Debug\Panel\ExtensionPanelInterface>
```

Returns the panels the application enabled.

**Returns**

`list<`[`Yii3\Debug\Panel\ExtensionPanelInterface`](/docs/extensions/yii3-debug/reference/panel/extensionpanelinterface/index.md)`>`: Enabled panels in navigation order.

### panelsWithBuiltIn() <span id="method-panelsWithBuiltIn"></span>

```php
public function panelsWithBuiltIn(Yii3\Debug\Panel\ExtensionPanelInterface $builtIn): list<Yii3\Debug\Panel\ExtensionPanelInterface>
```

Returns the built-in panel first, unless the application explicitly registered an override with the same ID.

A built-in whose ID the configuration disabled is dropped instead of placed first.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$builtIn` | [`Yii3\Debug\Panel\ExtensionPanelInterface`](/docs/extensions/yii3-debug/reference/panel/extensionpanelinterface/index.md) | Built-in panel to place first. |

**Returns**

`list<`[`Yii3\Debug\Panel\ExtensionPanelInterface`](/docs/extensions/yii3-debug/reference/panel/extensionpanelinterface/index.md)`>`: Built-in and enabled panels in navigation order.

### panelsWithBuiltIns() <span id="method-panelsWithBuiltIns"></span>

```php
public function panelsWithBuiltIns(iterable<Yii3\Debug\Panel\ExtensionPanelInterface> $builtIns): list<Yii3\Debug\Panel\ExtensionPanelInterface>
```

Returns built-in panels first, replacing each one with an explicitly registered panel of the same ID.

A built-in whose ID the configuration disabled is dropped instead of placed first.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$builtIns` | `iterable<`[`Yii3\Debug\Panel\ExtensionPanelInterface`](/docs/extensions/yii3-debug/reference/panel/extensionpanelinterface/index.md)`>` | Built-in panels in navigation order. |

**Returns**

`list<`[`Yii3\Debug\Panel\ExtensionPanelInterface`](/docs/extensions/yii3-debug/reference/panel/extensionpanelinterface/index.md)`>`: Built-in and enabled panels in navigation order.

### withCollector() <span id="method-withCollector"></span>

```php
public function withCollector(PHPForge\Debug\CollectorInterface $collector): self
```

Returns a copy with one more enabled collector appended.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$collector` | [`CollectorInterface`](https://github.com/php-forge/debug/blob/e4fbb8c3238a4d011ceef5e0094344abd50deaf4/src/CollectorInterface.php) | Collector to enable. |

**Returns**

`self`: Registry including the collector.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): when the collector ID is empty or already registered.

### withPanel() <span id="method-withPanel"></span>

```php
public function withPanel(Yii3\Debug\Panel\ExtensionPanelInterface|PHPForge\Debug\Panel $panel): self
```

Returns a copy with one more enabled panel appended.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$panel` | [`Yii3\Debug\Panel\ExtensionPanelInterface`](/docs/extensions/yii3-debug/reference/panel/extensionpanelinterface/index.md)`\|PHPForge\Debug\Panel` | Panel to enable; a portable panel is adapted. |

**Returns**

`self`: Registry including the panel.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): when the panel ID is empty or already registered.