PHPackages                             io4n/yii2-dump - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. io4n/yii2-dump

ActiveYii2-extension[Database &amp; ORM](/categories/database)

io4n/yii2-dump
==============

Generate the schema from an existing database

1.0.8(6y ago)02.8kBSD-3-ClausePHPPHP &gt;=5.5.0

Since Sep 10Pushed 6y agoCompare

[ Source](https://github.com/io4n/yii2-dump)[ Packagist](https://packagist.org/packages/io4n/yii2-dump)[ Docs](https://github.com/io4n/yii2-dump)[ RSS](/packages/io4n-yii2-dump/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)DependenciesVersions (10)Used By (0)

yii2-dump
=========

[](#yii2-dump)

Generate migration file from an existing database

> [github: https://github.com/Hzhihua/yii2-dump](https://github.com/Hzhihua/yii2-dump)
> [oschina: http://git.oschina.net/hzhihua/yii2-dump](http://git.oschina.net/hzhihua/yii2-dump)

Demo
----

[](#demo)

[![yii2-dump](https://raw.githubusercontent.com/wiki/Hzhihua/yii2-dump/yii2-dump.png)](https://raw.githubusercontent.com/wiki/Hzhihua/yii2-dump/yii2-dump.png)

Test Environment
----------------

[](#test-environment)

- PHP &gt;= 5.5.0
- MySQL(5.6.36)

Installation
------------

[](#installation)

```
composer require --prefer-dist "hzhihua/yii2-dump:1.0.3"

```

Configuration
-------------

[](#configuration)

Add the following in console/config/main.php:

### Simple Configuration

[](#simple-configuration)

```
return [
    'controllerMap' => [
        'dump' => [
            'class' => 'hzhihua\dump\DumpController',
            'filePrefix' => '123456_654321',
            'tableOptions' => 'ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci', // if mysql >= 5.7, you can set “ENGINE=InnoDB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_unicode_ci”,
        ],
    ],
];
```

### Detail Configuration [see](src/DumpController.php)

[](#detail-configuration-see)

```
return [
    'controllerMap' => [
        'dump' => [
            'class' => 'hzhihua\\dump\\DumpController',
            'db' => 'db', // Connection
            'templateFile' => '@vendor/hzhihua/yii2-dump/templates/migration.php',
            'generatePath' => '@console/migrations',
            'table' => 'table1,table2', // select which table will be dump(default filter migration table)
            'filter' => 'table3,table4', // table3 and table4 will be filtered when generating migration file
            'limit' => '0,1000', // select * from tableName limit 0,1000
            'filePrefix' => '123456_654321',
            'tableOptions' => 'ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci', // if mysql >= 5.7, you can set “ENGINE=InnoDB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_unicode_ci”,
            // ... ...
        ],
    ],
];
```

Default Table Options
---------------------

[](#default-table-options)

```
ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci

```

> it was defined at "@vendor/hzhihua/yii2-dump/src/Migration.php" file [see](src/Migration.php)

Default Limit
-------------

[](#default-limit)

```
0,1000

```

Default Filter Table
--------------------

[](#default-filter-table)

> migration

Tips
----

[](#tips)

> You may neet to remove the migration file that its name is "\*\_init.php" before you run "./yii migrate" commond. because it will generate "{{%user}}" table file when you run "./yii dump" commond and the file name with "\*\_init.php" also create "{{%user}}" table. it will tip you "{{%user}}" has always exits.

Simple Usage
------------

[](#simple-usage)

> run `dump` command.

```
cd /path/to/your-project
./yii dump # default action: generate, it will gerate migration file

```

Commands
--------

[](#commands)

> Check help

```
./yii help dump

```

> print all over the table name without table prefix

```
./yii dump/list

```

> generate all over the table migration file(default filter migration table)

```
./yii dump
or
./yii dump/generate

```

> generate all over the table migration file but it only had some data between 0 and 10

```
./yii dump -limit=10

```

> only generate table1,table2 migration file

```
./yii dump -table=table1,table2

```

> only generate table1,table2 migration file and only table1 will be dumped table data

```
./yii dump -table=table1,table2 -data=table1

```

> generate all over the migration table file without table1,table2

```
./yii dump -filter=table1,table2

```

> print all over the code of migration table file(default filter migration table)

```
./yii dump/create

```

> Display the 'createTable' code at the terminal.

```
./yii dump/create

```

> Display the 'dropTable' code at the terminal.

```
./yii dump/drop

```

> -type params

```
./yii dump -type=0/1/2/3
>>> -type=0 generate table migration file,
>>> -type=1 generate table data migration file,
>>> -type=2 generate add key migration file,
>>> -type=3 generate add foreign key migration file

```

> Useful commands (for macOS user):

```
./yii dump | pbcopy
./yii dump/drop | pbcopy

```

Supports
--------

[](#supports)

- Types
- Size
- Unsigned
- NOT NULL
- DEFAULT Value
- COMMENT
- Unique key
- Foreign key
- Primary key
- ENUM type (for MySQL)
- AUTO\_INCREMENT

Not Supports
------------

[](#not-supports)

AUTO\_INCREMENT

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 54.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~92 days

Recently: every ~17 days

Total

9

Last Release

2427d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.4.0

1.0.3PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1aa4533bc38c7a950aae7a1c7b0a80c3eea8c93f035a79949b5f59df8f6229c4?d=identicon)[johann](/maintainers/johann)

---

Top Contributors

[![Hzhihua](https://avatars.githubusercontent.com/u/18823393?v=4)](https://github.com/Hzhihua "Hzhihua (24 commits)")[![io4n](https://avatars.githubusercontent.com/u/1568040?v=4)](https://github.com/io4n "io4n (20 commits)")

---

Tags

migrationdatabasegeneratoryii2extensioncommandio4n

### Embed Badge

![Health badge](/badges/io4n-yii2-dump/health.svg)

```
[![Health](https://phpackages.com/badges/io4n-yii2-dump/health.svg)](https://phpackages.com/packages/io4n-yii2-dump)
```

###  Alternatives

[hzhihua/yii2-dump

Generate the schema from an existing database

1828.5k1](/packages/hzhihua-yii2-dump)[odan/phinx-migrations-generator

Migration generator for Phinx

235847.8k23](/packages/odan-phinx-migrations-generator)[dmstr/yii2-migrate-command

Console Migration Command with multiple paths/aliases support

31295.5k6](/packages/dmstr-yii2-migrate-command)[johnitvn/yii2-ajaxcrud

Gii CRUD template for Single Page Ajax Administration for yii2

97209.6k16](/packages/johnitvn-yii2-ajaxcrud)[webonaute/doctrine-fixtures-generator-bundle

Generate Fixture from your existing data in your database. You can specify the Entity name and the IDs you want to import in your fixture.

67184.1k](/packages/webonaute-doctrine-fixtures-generator-bundle)[c006/yii2-migration-utility

Automatically writes the create tables for migrations or create tables in general

63160.6k1](/packages/c006-yii2-migration-utility)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
