# BootstrapInterface

> BootstrapInterface is the interface that should be implemented by classes who want to participate in the application bootstrap process.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [base](/docs/api/yii/base/index.md) › BootstrapInterface

| interface | `yii\base\BootstrapInterface` |
| --- | --- |
| Since | 2.0 |
| Source | [`framework/base/BootstrapInterface.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/base/BootstrapInterface.php#L56) |

Implemented by 5 types:

- [`yii\filters\ContentNegotiator`](/docs/api/yii/filters/contentnegotiator/index.md)
- [`yii2\extensions\bootstrap6\Bootstrap`](/docs/extensions/bootstrap6/reference/bootstrap/index.md)
- [`yii2\extensions\filepond\Bootstrap`](/docs/extensions/filepond/reference/bootstrap/index.md)
- [`yii\debug\Module`](/docs/extensions/debug/reference/module/index.md)
- [`yii\inertia\Bootstrap`](/docs/extensions/inertia/reference/bootstrap/index.md)

BootstrapInterface is the interface that should be implemented by classes who want to participate in the application bootstrap process.

The main method [`bootstrap()`](/docs/api/yii/base/bootstrapinterface/index.md#method-bootstrap) will be invoked by an application at the beginning of its `init()` method.

Bootstrapping classes can be registered in two approaches.

The first approach is mainly used by extensions and is managed by the Composer installation process.
You mainly need to list the bootstrapping class of your extension in the `composer.json` file like following,

```
{
    // ...
    "extra": {
        "bootstrap": "path\\to\\MyBootstrapClass"
    }
}
```

If the extension is installed, the bootstrap information will be saved in [`Application::$extensions`](/docs/api/yii/base/application/index.md#property-extensions).

The second approach is used by application code which needs to register some code to be run during
the bootstrap process. This is done by configuring the [`Application::bootstrap()`](/docs/api/yii/base/application/index.md#method-bootstrap) property:

```
return [
    // ...
    'bootstrap' => [
        "path\\to\\MyBootstrapClass1",
        [
            'class' => "path\\to\\MyBootstrapClass2",
            'prop1' => 'value1',
            'prop2' => 'value2',
        ],
    ],
];
```

As you can see, you can register a bootstrapping class in terms of either a class name or a configuration class.

For more details and usage information on BootstrapInterface, see the [guide article on bootstrapping applications](/docs/guide/structure-applications/index.md).

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`bootstrap()`](#method-bootstrap) abstract | Bootstrap method to be called during application bootstrap stage. | `BootstrapInterface` |

## Method details

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

```php
abstract public function bootstrap(yii\base\Application $app): mixed
```

Bootstrap method to be called during application bootstrap stage.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$app` | [`Application`](/docs/api/yii/base/application/index.md) | The application currently running |

**Returns**

`mixed`