yiisoft / yii-gii
Yii Framework Code Generator Extension
Requires
- php: 8.1 - 8.5
- httpsoft/http-basis: ^1.1.2
- phpspec/php-diff: ^1.1.3
- psr/http-message: ^1.0 || ^2.0
- symfony/console: ^6.4.36 || ^7.0
- yiisoft/aliases: ^3.1.1
- yiisoft/csrf: ^2.2.3
- yiisoft/data-response: ^2.2
- yiisoft/friendly-exception: ^1.2
- yiisoft/http: ^1.3
- yiisoft/hydrator: ^1.6.3
- yiisoft/injector: ^1.2.1
- yiisoft/input-http: ^1.0.1
- yiisoft/router: ^4.0.2
- yiisoft/strings: ^2.7
- yiisoft/validator: ^2.5.1
- yiisoft/var-dumper: ^1.7.1
- yiisoft/yii-console: ^2.4.2
- yiisoft/yii-middleware: ^1.1.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- jetbrains/phpstorm-attributes: ^1.2
- maglnet/composer-require-checker: ^4.7.1
- nyholm/psr7: ^1.8.2
- phpunit/phpunit: ^10.5.63
- rector/rector: ^2.4.2
- roave/infection-static-analysis-plugin: ^1.35
- spatie/phpunit-watcher: ^1.24.4
- vimeo/psalm: ^5.26.1 || ^6.12
- yiisoft/active-record: ^1.0.2
- yiisoft/cache: ^3.2
- yiisoft/code-style: ^1.0
- yiisoft/db-sqlite: ^2.0.0
- yiisoft/di: ^1.4.1
- yiisoft/dummy-provider: ^1.1.0
- yiisoft/event-dispatcher: ^1.1
- yiisoft/files: ^2.1
- yiisoft/log: ^2.2.1
- yiisoft/translator: ^3.2.1
Suggests
- yiisoft/active-record: Required to use the Active Record generator.
- yiisoft/db-mssql: Required to use the Active Record generator with MSSQL.
- yiisoft/db-mysql: Required to use the Active Record generator with MySQL.
- yiisoft/db-oracle: Required to use the Active Record generator with Oracle.
- yiisoft/db-pgsql: Required to use the Active Record generator with PostgreSQL.
- yiisoft/db-sqlite: Required to use the Active Record generator with SQLite.
This package is auto-updated.
Last update: 2026-05-30 10:29:55 UTC
README
Gii: Yii3 code generator
This package provides code generation tools, called Gii, for Yii3 applications.
Gii includes JSON API endpoints and console commands for generating application code.
Requirements
- PHP 8.1 - 8.5.
Installation
The package could be installed with Composer:
composer require --dev yiisoft/yii-gii
In an application using yiisoft/config, Gii configuration is added automatically by the Composer config plugin.
The Active Record generator is optional. To use it, install
yiisoft/active-record, a concrete Yii DB
driver, and configure Yiisoft\Db\Connection\ConnectionInterface. For SQLite:
composer require yiisoft/active-record yiisoft/db-sqlite
Use the driver package that matches your database, such as yiisoft/db-mysql, yiisoft/db-pgsql, or
yiisoft/db-sqlite, and make sure the matching PDO extension is installed.
You need to define Yiisoft\Db\Connection\ConnectionInterface in your application if it is not already defined. See the
Yii DB SQLite connection guide for a
SQLite configuration example.
General usage
Gii registers JSON API routes under /gii/api when yiisoft/yii-gii.enabled is true.
GET /gii/api/generator
GET /gii/api/generator/{generator}
POST /gii/api/generator/{generator}/preview
POST /gii/api/generator/{generator}/generate
POST /gii/api/generator/{generator}/diff
By default, only localhost is allowed:
'yiisoft/yii-gii' => [ 'allowedIPs' => ['127.0.0.1', '::1'], ],
Console commands are registered automatically:
./yii help gii:controller ./yii gii:controller SampleController --actions=index --viewsPath=@runtime/gii-views --no-interaction ./yii help gii:active-record ./yii gii:active-record city --namespace=App\\Model --no-interaction
The Active Record command requires the table to exist in the configured database.
Documentation
If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.
License
Gii: Yii3 code generator is free software. It's released under the terms of the BSD License.
Please see LICENSE for more information.
Maintained by Yii Software.