yiisoft/yii-gii

Yii Framework Code Generator Extension

Maintainers

Package info

github.com/yiisoft/yii-gii

Chat

Forum

Wiki

pkg:composer/yiisoft/yii-gii

Fund package maintenance!

Opencollective

yiisoft

Statistics

Installs: 29 974

Dependents: 5

Suggesters: 0

Stars: 33

Open Issues: 14

dev-master / 3.0.x-dev 2026-05-30 10:28 UTC

This package is auto-updated.

Last update: 2026-05-30 10:29:55 UTC


README

Yii

Gii: Yii3 code generator


Latest Stable Version Total Downloads Build status Code Coverage Mutation testing badge Static analysis type-coverage

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.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack