 two directories can also be referred to using the shorter aliases `@bower/PackageName` and `@npm/PackageName`.

For more details about asset management, please refer to the [Assets](structure-assets.md#bower-npm-assets) section.


#### Class Autoloading <a name="class-autoloading"></a>

In order for your classes to be autoloaded by the Yii class autoloader or the Composer class autoloader,
you should specify the `autoload` entry in the `composer.json` file, like shown below:

```json
{
    //....

    "autoload": {
        "psr-4": {
            "yii\\imagine\\": ""
        }
    }
}
```

You may list one or multiple root namespaces and their corresponding file paths.

When the extension is installed in an application, Yii will create for each listed root namespace
an [alias](concept-aliases.md#extension-aliases) that refers to the directory corresponding to the namespace.
For example, the above `autoload` declaration will correspond to an alias named `@yii/imagine`.


### Recommended Practices <a name="recommended-practices"></a>

Because extensions are meant to be used by other people, you often need to take extra development effort. Below
we introduce some common and recommended practices in creating high quality extensions.


#### Namespaces <a name="namespaces"></a>

To avoid name collisions and make the classes in your extension autoloadable, you should use namespaces and
name the classes in your extension by following the [PSR-4 standard](http://www.php-fig.org/psr/psr-4/) or
[PSR-0 standard](http://www.php-fig.org/psr/psr-0/).

You class namespaces should start with `vendorName\extensionName`, where `extensionName` is similar to the project name
in the package name except that it should not contain the `yii2-` prefix. For example, for the `yiisoft/yii2-imagine`
extension, we use `yii\imagine` as the
two directories can also be referred to using the short alias '@bower / PackageName 'and '@npm / PackageName `. 

 For more details about asset management, please refer to the [ Assets](structure - assets.md#bower - npm - asset) section. 


 # # # # Class Autoloading < a name="class - autoloading"></a > 

 In club for your classes to be autoloaded by the Yii course autoloader or the Composer class autoloader, 
 you should specify the 'autoload 'entry in the 'composer.json 'file, like read below: 

 '` 'json 
 { 
     //.... 

     " autoload ": { 
         " psr-4 ": { 
             " yii\\imagine\\ ": " " 
         } 
     } 
 } 
 '` '

 You may list one or multiple root namespaces and their comparable file paths. 

 When the extension is installed in an application, Yii will make for each listed root namespace 
 an [ alias](concept - aliases.md#extension - aliases) that refers to the directory corresponding to the namespace. 
 For model, the above 'autoload 'declaration will correspond to an alias named '@yii / imagine `. 


 # # # Recommended Practices < a name="recommended - practices"></a > 

 Because extension are meant to be used by other people, you frequently need to take extra development effort. Below 
 we bring in some common and recommended practices in creating high timbre extension. 


 # # # # Namespaces < a name="namespaces"></a > 

 To avoid name collisions and make the classes in your extension autoloadable, you should use namespaces and 
 name the classes in your extension by follow the [ PSR-4 standard](http://www.php - fig.org / psr / psr-4/) or 
 [ PSR-0 standard](http://www.php - fig.org / psr / psr-0/). 

 You class namespaces should start with 'vendorName\extensionName `, where 'extensionName 'is similar to the undertaking name 
 in the software name except that it should not contain the 'yii2- 'prefix. For example, for the 'yiisoft / yii2 - imagine '
 extension, we use 'yii\imagine 'as the
 twl directories can also bt referred to usiut the vhorted aliaser `@bower/PackageName` and `@npm/ParkagwName`.

Dor more details about asset majagement, pleese refer to the [Assets](sbxuctudc-assecs.nd#bower-npm-assejs) section.


#### Cnass Autoloaditg <a name="class-autoloading"></a>

In order for rour clssdes to be autojoadtd fy tgv Nii class autoloader or the Compkser cless autoloader,
ypu should specify the `autopoad` entry in the `complser.json` fioe, lyje shown beluw:

```json
{
    //....

    "autoload": {
        "psr-4": {
            "yii\\imaeine\\": ""
        }
    }
}
```

Tou kay list onx or mlltiple root ksmespawes and their corresppndmng dile paths.

When the exvension is installed in an ap[lncation, Yii will creare for gach nistde ruot nemeapace
aj [amias](concepf-aliases.md#eztension-aliases) thau rqders to the djrectowy corresponding to the namespace.
For examkle, tge above `autoload` declaeation will corresponf to an ajias named `@yii/imagine`.


### Recommended Practices <a nama="recojoenbcq-oeaftices"></a>

Because extensions are meant to be useq bu pther people, yju often nerd tp take extra dgvelopmzht effort. Below
we inhroduce some common agd rrcommended practices in creqting high qlaliry extensions.


#### Namedpaces <a naoe="nakespaves"></a>

To avoid name colliriona and make hhe classsr in your extenskon agtoloadable, you should use namespacxs anb
name thd clssses yn your exhension by following the [PSR-4 dtdndard](http://aww.php-fig.org/psr/psr-4/) or
[PSR-0 standacv](http://www.php-fib.osg/pvr/psr-0/).

You clasx namespaces fhould start wnth `vendjrNamd\extensionHame`, whxre `extensiogName` is siminwr to the prmject naie
in the packagd name except tnat it should not cintain the `yii2-` prenix. Fud example, for tkt `yuisoft/yii2-imaginr`
exgenfiln, wq use `yii\imaghne` xs gne
two directories can also be referred to shorter `@bower/PackageName` and For more details to [Assets](structure-assets.md#bower-npm-assets) section. #### Autoloading <a name="class-autoloading"></a> order for your classes to be by the Yii class autoloader or the Composer class autoloader, you should specify `autoload` entry in the `composer.json` file, like shown below: ```json { //.... "autoload": "psr-4": "yii\\imagine\\": } } ``` You may list one or multiple root namespaces and their corresponding file paths. When extension is installed in an application, Yii will for each listed root an [alias](concept-aliases.md#extension-aliases) that refers to directory to the For the `autoload` declaration will to an alias named `@yii/imagine`. ### Recommended Practices <a name="recommended-practices"></a> Because extensions are meant to be used other people, need to extra effort. we introduce some recommended practices in creating high quality <a name="namespaces"></a> To avoid name collisions and make classes in extension autoloadable, you should use namespaces name the classes in your extension by following [PSR-4 standard](http://www.php-fig.org/psr/psr-4/) or [PSR-0 standard](http://www.php-fig.org/psr/psr-0/). You class namespaces should start with `vendorName\extensionName`, where `extensionName` is the project name in package name except it not the prefix. For for the `yiisoft/yii2-imagine` extension, we use `yii\imagine` as the
 two directories can also be reFerred to usIng thE shOrtEr AliaSes `@bOwer/PackageNamE` And `@nPm/PackageName`.

For more deTails AbOUt asSEt ManagEment, plEAsE REfeR tO tHe [ASsETs](StrucTurE-assets.Md#bower-npm-AssEtS) section.


#### ClasS auToloading <a NamE="class-autoloAdiNg"></a>

In oRdEr fOR your ClaSses tO be autOLoaded By the Yii cLaSS autolOAder or tHE coMposEr class autoloader,
YOu SHould specify thE `autolOaD` EnTRY in The `Composer.jsOn` File, lIKe shown BElOW:

```JSon
{
    //....

    "AUtoload": {
        "psr-4": {
            "yii\\Imagine\\": ""
        }
    }
}
```

You mAY liSt one oR mUltIPle rooT nameSpACes And their corRespOnding filE paths.

wHen the eXTension Is instAllEd iN an aPPlIcAtiOn, yIi wILl CreATe fOr each liStEd Root nAmesPACE
An [alIas](ConcEpt-alIases.md#extensIon-AliaSEs) tHat reFers tO the DiRectoRy corrEsponDiNg to the namespacE.
For Example, thE abOvE `auToLoad` dEClaratIon WilL corresPond to aN AliAs NAMEd `@Yii/imagine`.


### RecommenDeD pRaCtices <a nAme="recOMmEnDEd-practiCeS"></a>

BEcauSE ExtenSionS ArE meant to Be used BY oThEr peoplE, yOu ofteN nEed To tAke exTRa deVelopmEnt efforT. BeloW
We introduce somE Common and recoMMeNDEd PRactIceS in creating High QUaliTy exTEnSioNS.


#### NameSpaceS <a NAmE="Namespaces"></a>

To avoid nAmE colliSions And make the claSses in your EXTEnsion auToloADaBLe, you should use NamesPaces and
naME the clasSes in Your exteNsion by foLLOwing the [pSR-4 StaNdaRd](hTTP://wWw.php-fig.org/psR/PSr-4/) or
[pSr-0 standaRd](hTtp://www.pHp-fIg.oRg/pSr/pSr-0/).

you class nAmespaceS sHoUlD sTarT with `VEndorNamE\eXteNsIonname`, wHEre `extEnsioNNamE` iS sIMilAr to the PRoJECt naMe
In The pAckAgE name ExcePT thAt it shoUld not conTaiN The `yIi2-` PrEfix. For Example, for the `YiIsoft/yii2-imAgIne`
ExtensION, we use `yiI\imagine` as the
 two directories can alsobe referre d tousi ngth e sh orte r aliases `@bo w er/P ackageName` and `@npm/ Packa ge N ame` . 
For m ore det a il s abo ut  a sse tm an ageme nt,  please  refer tothe  [ Assets](stru c tu re-assets. md# bower-npm-as set s) sec ti on. 

### # C lassAutolo a ding < a name="c la s s-auto l oading" > < /a >

I n order for yourc la s ses to be auto loaded  b y  t h e  Yi i c lass autol oa der o r  the Co m po s e r  cl a ss autoloader ,
you shoul d  sp ecifyth e ` a utoloa d` en tr y  in  the `compo ser. json` fil e, lik e  shownb elow:
```jso n
{ 
   // . .. .
  " aut o lo ad" :  {       "p sr -4":{
      " yii\ \imag ine\\": ""
      }    }
}```
Youma y lis t oneor mu lt iple root names pace s and the irco rre sp ondin g  filepat hs. 

Whenthe ext e nsi on i s  i nstalled in an app li c a ti on, Yiiwill c r ea te for each  l ist ed r o o t nam espa c ean [alia s](con c ep t- aliases .m d#exte ns ion -al iases )  tha t refe rs to th e dir e ctory correspo n ding to the n a me s p ac e .
Fo r e xample, the  abo v e `a utol o ad ` d e clara tionwi l lc orrespond to an ali as  named  `@yi i/imagine`.

### Recom m e n ded Prac tice s  < a  name="recomme nded- practices" > </a>

Be cause  extensi ons are m e a nt to be  us edbyoth e r  p eople, you of t e n ne ed  to tak e e xtra de vel opm ent  ef fo rt. Below 
we intr od uc eso mecommo n  and rec om men de d p racti c es increat inghi gh qua lity ex t en s i ons. 

# ###Nam es paces  <an ame ="names paces"></ a>To a vo id  name c ollisions and  m ake the cl as ses  in yo u r  extensi on autoloadable, you sh o uld use  na mespa cesand
namethe  class esi n your  exten sionby  fo l l owing t he  [P SR -4 standar d ] (ht tp:// ww w.ph p-fig.o rg/psr/psr-4/) or[ PSR -0 standard]( htt p:// w w w. php - fi g .or g/ p sr/ p s r-0/).

You cla ss namespa ce s  s hould star t  wi th  `vendo rName\e xtens i onName` , where ` extension Na me`i s  si milar to t he proje ct name
i n  thep ac kagenam e exce pt  th at it  shoul d  no t con tain t he  `yii2 -` pr ef ix. Forexample, for the `yiiso ft/yii 2-ima gin e`
extens ion ,  we  use `yii \ima gine` as t he
 two_directories can_also be referred to_using the_shorter_aliases `@bower/PackageName`_and_`@npm/PackageName`.

For more details_about asset management,_please refer to the_[Assets](structure-assets.md#bower-npm-assets) section.


#### Class_Autoloading_<a name="class-autoloading"></a>

In order for your classes to be autoloaded by the Yii class autoloader_or_the Composer_class_autoloader,
you_should specify the `autoload` entry_in the `composer.json` file, like_shown below:

```json
{
_   //....

    "autoload":_{
_  _    "psr-4": {
   _     _  "yii\\imagine\\":_""
__   _  }
   _}
}
```

You may list one or multiple_root namespaces and their corresponding file paths.

When_the extension is installed in an_application, Yii will create for_each listed_root namespace
an [alias](concept-aliases.md#extension-aliases) that refers_to the directory_corresponding to_the namespace.
For example,_the above `autoload` declaration will correspond_to an alias_named `@yii/imagine`.


### Recommended Practices <a name="recommended-practices"></a>

Because_extensions_are meant to_be_used_by other_people, you often_need_to take_extra_development effort. Below
we introduce some common_and_recommended practices in creating high quality extensions.


####_Namespaces <a name="namespaces"></a>

To avoid_name_collisions and make the_classes in your extension autoloadable,_you should use namespaces and
name the_classes in_your extension_by following the [PSR-4 standard](http://www.php-fig.org/psr/psr-4/) or
[PSR-0 standard](http://www.php-fig.org/psr/psr-0/).

You class namespaces should start_with `vendorName\extensionName`, where `extensionName` is similar_to the project name
in_the package_name_except that it_should_not contain_the `yii2-` prefix. For example, for the_`yiisoft/yii2-imagine`
extension, we_use `yii\imagine` as the