Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
24108266
Commit
24108266
authored
Nov 10, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
git://github.com/yiisoft/yii2
parents
a61c8692
bf47650f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
concept-autoloading.md
docs/guide/concept-autoloading.md
+3
-3
No files found.
docs/guide/concept-autoloading.md
View file @
24108266
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment