# AssetCollector

> Captures yiisoft/assets bundles loaded during the request for the Asset Bundles panel.

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

| final class | `Yii3\Debug\Collector\AssetCollector` |
| --- | --- |
| Implements | [`CollectorInterface`](https://github.com/php-forge/debug/blob/e4fbb8c3238a4d011ceef5e0094344abd50deaf4/src/CollectorInterface.php) |
| Source | [`src/Collector/AssetCollector.php`](https://github.com/yii3/debug/blob/main/src/Collector/AssetCollector.php#L17) |

Captures `yiisoft/assets` bundles loaded during the request for the Asset Bundles panel.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`capture()`](#method-capture) | Encodes the captured bundles into the Asset Bundles panel payload. | `AssetCollector` |
| [`collect()`](#method-collect) | Narrows one loaded bundle into a typed row, keyed by class name so a repeated load never duplicates it. | `AssetCollector` |
| [`id()`](#method-id) | Returns the stable identifier of this collector. | `AssetCollector` |
| [`shutdown()`](#method-shutdown) | Stops capturing and clears the bundles accumulated for the request. | `AssetCollector` |
| [`startup()`](#method-startup) | Starts capturing, discarding anything left from a previous request. | `AssetCollector` |

## Method details

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

```php
public function capture(): array<string, mixed>|null
```

Encodes the captured bundles into the Asset Bundles panel payload.

**Returns**

`array<string, mixed>|null`: Encoded Asset panel payload; `null` when the collector never started.

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

```php
public function collect(Yiisoft\Assets\AssetBundle $bundle, string $name): void
```

Narrows one loaded bundle into a typed row, keyed by class name so a repeated load never duplicates it.

The debugger's own toolbar bundle is excluded because it is infrastructure rather than application content.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$bundle` | `Yiisoft\Assets\AssetBundle` | Bundle the loader resolved. |
| `$name` | `string` | Bundle class name the loader was asked for. |

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

```php
public function id(): string
```

Returns the stable identifier of this collector.

**Returns**

`string`: Stable ID pairing this collector with its panel.

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

```php
public function shutdown(): void
```

Stops capturing and clears the bundles accumulated for the request.

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

```php
public function startup(): void
```

Starts capturing, discarding anything left from a previous request.