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
d570d3ae
Commit
d570d3ae
authored
Oct 01, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added missing DI container to yii2 and yii1 tut
fixes #5218
parent
24ef2516
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
tutorial-yii-integration.md
docs/guide/tutorial-yii-integration.md
+7
-5
No files found.
docs/guide/tutorial-yii-integration.md
View file @
d570d3ae
...
@@ -101,7 +101,8 @@ new yii\web\Application($yiiConfig); // Do NOT call run() here
...
@@ -101,7 +101,8 @@ new yii\web\Application($yiiConfig); // Do NOT call run() here
As you can see, the code above is very similar to that in the
[
entry script
](
structure-entry-scripts.md
)
of
As you can see, the code above is very similar to that in the
[
entry script
](
structure-entry-scripts.md
)
of
a typical Yii application. The only difference is that after the application instance is created, the
`run()`
method
a typical Yii application. The only difference is that after the application instance is created, the
`run()`
method
is not called. This is because by calling
`run()`
, Yii will take over the control of the request handling workflow.
is not called. This is because by calling
`run()`
, Yii will take over the control of the request handling workflow
which is not needed in this case and already handled by the existing application.
Like in a Yii application, you should configure the application instance based on the environment running
Like in a Yii application, you should configure the application instance based on the environment running
the third-party system. For example, to use the
[
Active Record
](
db-active-record.md
)
feature, you need to configure
the third-party system. For example, to use the
[
Active Record
](
db-active-record.md
)
feature, you need to configure
...
@@ -118,9 +119,9 @@ the whole application in Yii 2, you may just want to enhance it using some of th
...
@@ -118,9 +119,9 @@ the whole application in Yii 2, you may just want to enhance it using some of th
This can be achieved as described below.
This can be achieved as described below.
> Note: Yii 2 requires PHP 5.4 or above. You should make sure that both your server and the existing application
> Note: Yii 2 requires PHP 5.4 or above. You should make sure that both your server and the existing application
support this.
>
support this.
First, install Yii 2 in your existing application by following the instructions given in the
last subsection
.
First, install Yii 2 in your existing application by following the instructions given in the
[
last subsection
](
#using-yii-in-others
)
.
Second, modify the entry script of the application as follows,
Second, modify the entry script of the application as follows,
...
@@ -149,13 +150,14 @@ require($yii1path . '/YiiBase.php'); // Yii 1.x
...
@@ -149,13 +150,14 @@ require($yii1path . '/YiiBase.php'); // Yii 1.x
class
Yii
extends
\yii\BaseYii
class
Yii
extends
\yii\BaseYii
{
{
// copy-paste the code
in
YiiBase (1.x) here
// copy-paste the code
from
YiiBase (1.x) here
}
}
Yii
::
$classMap
=
include
(
$yii2path
.
'/classes.php'
);
Yii
::
$classMap
=
include
(
$yii2path
.
'/classes.php'
);
// register Yii2 autoloader via Yii1
// register Yii2 autoloader via Yii1
Yii
::
registerAutoloader
([
'Yii'
,
'autoload'
]);
Yii
::
registerAutoloader
([
'Yii'
,
'autoload'
]);
// create the dependency injection container
Yii
::
$container
=
new
yii\di\Container
;
```
```
That's all! Now in any part of your code, you can use
`Yii::$app`
to access the Yii 2 application instance, while
That's all! Now in any part of your code, you can use
`Yii::$app`
to access the Yii 2 application instance, while
...
...
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