mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-14 13:25:23 +08:00
Edited "Starting" Section
Not clear how define('YII_ENV', 'dev') creates the YII_ENV_DEV
constant. Seems like an odd bit of magic that may confuse others…
This commit is contained in:
@@ -1,24 +1,22 @@
|
|||||||
Generating Code with Gii
|
Generating Code with Gii
|
||||||
========================
|
========================
|
||||||
|
|
||||||
In this section, we will describe how to use [Gii](tool-gii.md) to automatically generate the code
|
This section will describe how to use [Gii](tool-gii.md) to automatically generate code
|
||||||
that implements some common features. To achieve this goal, all you need is just to enter the needed
|
that implements some common Web site features. Using Gii to auto-generate code is simply a matter of entering the right information per to the instructions shown on the Gii Web pages.
|
||||||
information according to the instructions showing on the Gii Web pages.
|
|
||||||
|
|
||||||
Through this tutorial, you will learn
|
Through this tutorial, you will learn how to:
|
||||||
|
|
||||||
* How to enable Gii in your application;
|
* Enable Gii in your application
|
||||||
* How to use Gii to generate an Active Record class;
|
* Use Gii to generate an Active Record class
|
||||||
* How to use Gii to generate the code implementing the CRUD operations for a DB table.
|
* Use Gii to generate the code implementing the CRUD operations for a DB table
|
||||||
* How to customize the code generated by Gii.
|
* Customize the code generated by Gii
|
||||||
|
|
||||||
|
|
||||||
Starting Gii <a name="starting-gii"></a>
|
Starting Gii <a name="starting-gii"></a>
|
||||||
------------
|
------------
|
||||||
|
|
||||||
[Gii](tool-gii.md) is provided by Yii in terms of a [module](structure-modules.md). You can enable Gii
|
[Gii](tool-gii.md) is provided in Yii as a [module](structure-modules.md). You can enable Gii
|
||||||
by configuring it in the [[yii\base\Application::modules|modules]] property of the application. In particular,
|
by configuring it in the [[yii\base\Application::modules|modules]] property of the application. Depending upon how you created your application, you may find the following code is already provided in the `config/web.php` configuration file:
|
||||||
you may find the following code is already given in the `config/web.php` file - the application configuration,
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$config = [ ... ];
|
$config = [ ... ];
|
||||||
@@ -30,16 +28,16 @@ if (YII_ENV_DEV) {
|
|||||||
```
|
```
|
||||||
|
|
||||||
The above configuration states that when in [development environment](concept-configurations.md#environment-constants),
|
The above configuration states that when in [development environment](concept-configurations.md#environment-constants),
|
||||||
the application should include a module named `gii` which is of class [[yii\gii\Module]].
|
the application should include a module named `gii`, which is of class [[yii\gii\Module]].
|
||||||
|
|
||||||
If you check the [entry script](structure-entry-scripts.md) `web/index.php` of your application, you will
|
If you check the [entry script](structure-entry-scripts.md) `web/index.php` of your application, you will
|
||||||
find the following line which essentially makes `YII_ENV_DEV` to be true.
|
find the following line, which essentially makes `YII_ENV_DEV` to be true.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
defined('YII_ENV') or define('YII_ENV', 'dev');
|
defined('YII_ENV') or define('YII_ENV', 'dev');
|
||||||
```
|
```
|
||||||
|
|
||||||
Therefore, your application has already enabled Gii, and you can access it via the following URL:
|
Thanks to that line, your application is in development mode, and will have already enabled Gii, per the above configuration. You can now access Gii via the following URL:
|
||||||
|
|
||||||
```
|
```
|
||||||
http://hostname/index.php?r=gii
|
http://hostname/index.php?r=gii
|
||||||
|
|||||||
Reference in New Issue
Block a user