josemodi97/yii2-gii-datasource-generator Generate Yii2 models, search models, controllers and CRUD views for an entire database schema in one step, with connection ma... (see full description)

Yii2 Gii Datasource Generator

  1. Features
  2. Requirements
  3. Installation
  4. How it works
  5. Comparison to yii2-giiant
  6. License

Generate Yii2 models, search models, controllers and CRUD views for an entire database schema in one step — with connection management, live schema preview, and an ER diagram — instead of running Gii's Model and CRUD generators one table at a time.

Latest Stable Version Total Downloads License

Features

  • Connection registry — save multiple named database connections; each is tested live before it's stored, and persists automatically with zero manual edits to your app's config/web.php.
  • Schema preview with ER diagram — see every table and view in a connection's schema, with a live entity-relationship diagram rendered from real foreign key metadata.
  • Generate-all-at-once — pick the tables you want, review a single combined diff/preview screen covering every model, search model, controller, and CRUD view, then confirm once to write them all.
  • Collision-safe multi-connection support — every generated class and file is prefixed with the connection's name (e.g. inventory_dbInventoryDbOrder), so two connections that both have an order table never collide, and each model is pinned to its own database connection.
  • Correct relations — foreign-key-based relations between generated models point at the correct connection-prefixed class name in both directions, even across a full batch generation run.

Requirements

  • PHP >= 8.1
  • Yii2 (yiisoft/yii2 ~2.0.45)
  • yiisoft/yii2-gii ~2.2.0 (installed automatically as a dependency)
  • A relational database with a yii\db\Schema driver: MySQL/MariaDB, PostgreSQL, SQL Server, SQLite, Oracle, or CUBRID. Non-relational sources are not supported in this release.

Installation

Add the package with Composer:

composer require josemodi97/yii2-gii-datasource-generator

No further configuration is required — the extension registers itself into your application via Composer's extra.bootstrap mechanism on every request (the same pattern used by other zero-config Yii2 extensions), so config/web.php and config/console.php never need to be edited.

Once installed, visit /gii-datasource-generator/connection/index in your dev-environment application (access is restricted to 127.0.0.1/::1 by default, same as Gii itself — configure allowedIPs on the module if you need broader access).

How it works

  1. Add a connection — pick a driver, enter connection details, and it's tested live before being saved to config/gii-datasources.php (add this file to your .gitignore — it holds plaintext credentials, same trust boundary as Gii itself).
  2. Preview the schema — see every table/view, with an ER diagram for relational sources.
  3. Generate All — select the objects you want, review the combined file list (grouped into Models / Search Models / Controllers / Views, with inline diff/preview), then confirm.

Everything generated is placed in your app's normal models/, controllers/, and views/ folders, using the connection's name as a class/file prefix — so it's safe to run this against several databases in the same project.

Comparison to yii2-giiant

yii2-giiant is the established tool for batch-generating CRUD from a schema, using the db component your app already has configured. This package targets a different scenario: managing several independent database connections in one project through a UI (rather than one connection already wired into your app config), with a schema/ER preview step before generation, and connection-prefixed naming so multiple databases' generated code can never collide.

License

MIT — see LICENSE.

0 0
1
0
Yii Version: 2.0
License: MIT
Category: Database
    Developed by: Modi97 Modi97
    Created: Sep 6, 2026
    Updated: 2 days ago
    Packagist Profile
    Github Repository