Commit 5c4deb73 by Larry Ullman

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…
parent dfa0bc8d
Generating Code with Gii
========================
In this section, we will describe how to use [Gii](tool-gii.md) to automatically generate the code
that implements some common features. To achieve this goal, all you need is just to enter the needed
information according to the instructions showing on the Gii Web pages.
This section will describe how to use [Gii](tool-gii.md) to automatically generate code
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.
Through this tutorial, you will learn
Through this tutorial, you will learn how to:
* How to enable Gii in your application;
* How to use Gii to generate an Active Record class;
* How to use Gii to generate the code implementing the CRUD operations for a DB table.
* How to customize the code generated by Gii.
* Enable Gii in your application
* Use Gii to generate an Active Record class
* Use Gii to generate the code implementing the CRUD operations for a DB table
* Customize the code generated by Gii
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
by configuring it in the [[yii\base\Application::modules|modules]] property of the application. In particular,
you may find the following code is already given in the `config/web.php` file - the application configuration,
[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. Depending upon how you created your application, you may find the following code is already provided in the `config/web.php` configuration file:
```php
$config = [ ... ];
......@@ -30,16 +28,16 @@ if (YII_ENV_DEV) {
```
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
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
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
......
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