From 857feeb6ac0ee8090a8cbd67e93c350c38434cdd Mon Sep 17 00:00:00 2001 From: Tobias Munk Date: Thu, 12 Dec 2013 12:46:15 +0100 Subject: [PATCH] updated code style, added autoloading and prefix examples --- docs/guide/extensions.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/guide/extensions.md b/docs/guide/extensions.md index 202deb3..e20b4e3 100644 --- a/docs/guide/extensions.md +++ b/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 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. +- Extension SHOULD NOT use class prefixes (i.e. `TbNavBar`, `EMyWidget`, etc.) +- Extension SHOULD provide a valid PSR-0 autoloading configuration in `composer.json` + + **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