> Info: Extension classes are autoloaded using the [Yii class autoloader](concept-autoloading.md). Yii automatically
creates [aliases](concept-aliases.md#extension-aliases) for the root namespaces declared by the extensions.
Also make sure in the [application configuration](structure-applications.md#application-configurations), you have
configured `extension
> Info: Extension classes are autoloaded by the [Yii class autoloader](concept-autoloading.md).
## Creating Extensions
An extension can contain any code you like, such as a helper class, a widget, a module, etc.
You may consider creating an extension when you feel the need to redistribute some of your great code so that
they can be easily reused by other people or in your other projects.
An extension can contain any code you like, such as a helper class, a widget, a module, etc.
It is recommended that you create an extension in terms of a [Composer package](https://getcomposer.org/) so that
it can be more easily installed and used by other users, liked described in the last subsection.
### Basic Steps
Below are the basic steps you may follow to create an extension.
It is recommended that you create an extension in terms of a Composer package so that it can be more easily
used elsewhere, liked described in the last subsection. Below are the steps you may follow to create an extension.
1. Put all the files you plan to include in the extension in a single directory. The directory should contain
no other irrelevant files. For simplicity, let's call this directory the extension's *root directory*.
2. Create a `composer.json` file directly under the root directory. The file is required by Composer, which describes
the metadata about your extension. Please refer to the [Composer Manual](https://getcomposer.org/doc/01-basic-usage.md#composer-json-project-setup)
for more details about the file format.
3. Create a VCS (version control system) repository to host the extension files. Any future development
and maintenance work about the extension should be done on this repository.
4. Register your extension with a Composer repository so that other users can find and install your extension.
1. Create a project for your extension and host it on a VCS repository, such as [github.com](https://github.com).
Development and maintenance work about the extension should be done on this repository.
2. Under the root directory of the project, create a file named `composer.json` as required by Composer. Please
refer to the next subsection for more details.
3. Register your extension with a Composer repository so that other users can find and install your extension.
If you are creating an open source extension, you can register it with [Packagist](https://packagist.org/);
If you are creating a private extension for internal use, you may register it with
[your own repository](https://getcomposer.org/doc/05-repositories.md#hosting-your-own).
As an example, you may refer to the [yiisoft/yii2-bootstrap](widget-bootstrap) extension which provides a set of
widgets encapsulating the Twitter Bootstrap plugins. The extension is hosted on [GitHub](https://github.com/yiisoft/yii2-bootstrap)
and registered with [Packagist](https://packagist.org/packages/yiisoft/yii2-bootstrap). Below is the content
of its `composer.json` file (some unimportant content is removed for simplicity):
### `composer.json`
Each Composer package must have a `composer.json` file in its root directory. The file contains the metadata about
the package. You may find complete specification about this file in the [Composer Manual](https://getcomposer.org/doc/01-basic-usage.md#composer-json-project-setup).
You may also refer to the following example which is the `composer.json` file for the `yiisoft/yii2-imagine` extension:
```json
{
"name": "yiisoft/yii2-bootstrap",
"description": "The Twitter Bootstrap extension for the Yii framework",
"keywords": ["yii2", "bootstrap"],
//packagename
"name":"yiisoft/yii2-imagine",
//packagetype
"type":"yii2-extension",
"description":"The Imagine integration for the Yii framework",