Commit 24108266 by Qiang Xue

Merge branch 'master' of git://github.com/yiisoft/yii2

parents a61c8692 bf47650f
...@@ -3,7 +3,7 @@ Class Autoloading ...@@ -3,7 +3,7 @@ Class Autoloading
Yii relies on the [class autoloading mechanism](http://www.php.net/manual/en/language.oop5.autoload.php) Yii relies on the [class autoloading mechanism](http://www.php.net/manual/en/language.oop5.autoload.php)
to locate and include all required class files. It provides a high-performance class autoloader that is compliant to the to locate and include all required class files. It provides a high-performance class autoloader that is compliant to the
[PSR-4 standard](https://github.com/php-fig/fig-standards/blob/master/proposed/psr-4-autoloader/psr-4-autoloader.md). [PSR-4 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md).
The autoloader is installed when you include the `Yii.php` file. The autoloader is installed when you include the `Yii.php` file.
> Note: For simplicity of description, in this section we will only talk about autoloading of classes. However, keep in > Note: For simplicity of description, in this section we will only talk about autoloading of classes. However, keep in
...@@ -27,7 +27,7 @@ For example, if a class name and namespace is `foo\bar\MyClass`, the [alias](con ...@@ -27,7 +27,7 @@ For example, if a class name and namespace is `foo\bar\MyClass`, the [alias](con
would be `@foo/bar/MyClass.php`. In order for this alias to be resolvable into a file path, would be `@foo/bar/MyClass.php`. In order for this alias to be resolvable into a file path,
either `@foo` or `@foo/bar` must be a [root alias](concept-aliases.md#defining-aliases). either `@foo` or `@foo/bar` must be a [root alias](concept-aliases.md#defining-aliases).
When using the [Basic Application Template](start-basic.md), you may put your classes under the top-level When using the [Basic Application Template](start-installation.md), you may put your classes under the top-level
namespace `app` so that they can be autoloaded by Yii without the need of defining a new alias. This is because namespace `app` so that they can be autoloaded by Yii without the need of defining a new alias. This is because
`@app` is a [predefined alias](concept-aliases.md#predefined-aliases), and a class name like `app\components\MyClass` `@app` is a [predefined alias](concept-aliases.md#predefined-aliases), and a class name like `app\components\MyClass`
can be resolved into the class file `AppBasePath/components/MyClass.php`, according to the algorithm just described. can be resolved into the class file `AppBasePath/components/MyClass.php`, according to the algorithm just described.
...@@ -66,7 +66,7 @@ also install those. ...@@ -66,7 +66,7 @@ also install those.
When using the Yii autoloader together with other autoloaders, you should include the `Yii.php` file When using the Yii autoloader together with other autoloaders, you should include the `Yii.php` file
*after* all other autoloaders are installed. This will make the Yii autoloader the first one responding to *after* all other autoloaders are installed. This will make the Yii autoloader the first one responding to
any class autoloading request. For example, the following code is extracted from any class autoloading request. For example, the following code is extracted from
the [entry script](structure-entry-scripts.md) of the [Basic Application Template](start-basic.md). The first the [entry script](structure-entry-scripts.md) of the [Basic Application Template](start-installation.md). The first
line installs the Composer autoloader, while the second line installs the Yii autoloader: line installs the Composer autoloader, while the second line installs the Yii autoloader:
```php ```php
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment