Browse Source

updated code style, added autoloading and prefix examples

tags/2.0.0-beta
Tobias Munk 11 years ago
parent
commit
857feeb6ac
  1. 29
      docs/guide/extensions.md

29
docs/guide/extensions.md

@ -10,9 +10,34 @@ Code style
using the following syntax: e.g. `[[name()]]`, `[[name\space\MyClass::name()]]`.
- If you're displaying errors to developers do not translate these (i.e. do not use `\Yii::t()`). Errors should be
translated only if they're displayed to end users.
- Extension SHOULD NOT use class prefixes.
- Extension SHOULD NOT use class prefixes (i.e. `TbNavBar`, `EMyWidget`, etc.)
- Extension SHOULD provide a valid PSR-0 autoloading configuration in `composer.json`
- Especially for core components (eg. `WebUser`) additional functionality SHOULD be implemented using behaviors or traits instead subclassing.
**Example 1: Code in repository root**
```
./Class.php
```
```
"autoload": {
"psr-0": { "vendor\\package\\": "" }
},
```
**Example 2: Code in repository subfolder `./src`**
```
./src/vendor/package/Class.php
```
```
"autoload": {
"psr-0": { "vendor\\package\\": "./src" }
},
```
### Namespace and package names

Loading…
Cancel
Save