PHPackages                             tonychen/php-migration - 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. tonychen/php-migration

ActiveLibrary[Database &amp; ORM](/categories/database)

tonychen/php-migration
======================

v0.2.2(8y ago)1023PHPPHP &gt;=5.4

Since Jun 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/TonyChen-SH/php-migration)[ Packagist](https://packagist.org/packages/tonychen/php-migration)[ RSS](/packages/tonychen-php-migration/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (6)Dependencies (2)Versions (8)Used By (0)

php-migration 数据库更新维护管理库
------------------------

[](#php-migration-数据库更新维护管理库)

[![StyleCI](https://camo.githubusercontent.com/c7f5994a7639c28df03bfe5c84c1988b1c7817f17b2771c47e2dbf7c54d36bbf/68747470733a2f2f7374796c6563692e696f2f7265706f732f39333530343333372f736869656c643f6272616e63683d646576656c6f70)](https://styleci.io/repos/93504337)

### 如果有以下几种问题，那么你就来对地方了

[](#如果有以下几种问题那么你就来对地方了)

- 每次部署程序，都要手动导入数据？
- 每次数据库字段更新，都要手动去执行一遍？
- 服务器辣么多，更新数据库要一个一个的手动去执行？
- 团队协作，同事更新了数据库结构，我们用的不是同一个测试数据库，程序报错？

### 一个小工具，解决你的难题：

[](#一个小工具解决你的难题)

> php-migration是一个数据库更新维护管理库，每次的数据库结构的更改，都用sql语句的形式写下来，让php程序去执行。当前数据库版本执行完毕，version表对当前执行的数据库版本号进行记录，当下次执行的时候会进行比对。如果当前执行的版本小于等于version表的最近版本，就不做执行更新操作，如果大于最新版本，就执行更新操作

### Install

[](#install)

```
$ composer require tonychen/php-migration
```

或者

```
  // 把下面的代码片段，加入到composer.json文件里面
  "require": {
    "tonychen/php-migration": "^0.1.0"
  }
```

### Usage

[](#usage)

```
// 引入自动加载
require '../vendor/autoload.php';
require '../password.php';

use Tony\Migration\DbUpdate;

define('APP_PATH', __DIR__.'/../');
// 设置数据库版本文件路径。
define('DB_VERSION_PATH', APP_PATH.'example/DbVersion/');

$path = DB_VERSION_PATH;
// 初始化数据库版本工具[数据库配置,数据库版本文件文件夹路径]
$dbUpdate = new DbUpdate(['dsn' => 'mysql:host=127.0.0.1;dbname=migration;charset=utf8', 'user' => 'root', 'password' => '123456'], $path);
// 开始数据库版本升级
$dbUpdate->update();

// 具体的可以看下example底下有使用示例
// 数据库版本文件名，命名格式：V1.php ，V(大写)是必须有的字符，1代表当前版本号。 可以是>=1的任意整数，不可以重复
//    1.首先这是一个类文件
//    2.文件夹名与类名相同
//    3.集成与实现migration接口
```

[![table show](images/2018/01/table-show.png)](images/2018/01/table-show.png)

### TODO

[](#todo)

- 删除指定版本的版本号以后，可以把该版本号重新执行一遍
- 每个版本号，数据内需要更新内容的备注

### 许可

[](#许可)

本项目采用Apache License 2.0协议，了解更多请看协议文件。

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~64 days

Recently: every ~95 days

Total

7

Last Release

2926d ago

PHP version history (2 changes)v0.1PHP &gt;=5.4

v0.1.1PHP &gt;=5.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/27392605?v=4)[TonyChen-SH](/maintainers/TonyChen-SH)[@TonyChen-SH](https://github.com/TonyChen-SH)

---

Top Contributors

[![TonyChen-SH](https://avatars.githubusercontent.com/u/27392605?v=4)](https://github.com/TonyChen-SH "TonyChen-SH (51 commits)")

---

Tags

migrationdb update

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/tonychen-php-migration/health.svg)

```
[![Health](https://phpackages.com/badges/tonychen-php-migration/health.svg)](https://phpackages.com/packages/tonychen-php-migration)
```

###  Alternatives

[rector/rector

Instant Upgrade and Automated Refactoring of any PHP code

10.3k133.5M8.4k](/packages/rector-rector)[kitloong/laravel-migrations-generator

Generates Laravel Migrations from an existing database

2.9k7.9M33](/packages/kitloong-laravel-migrations-generator)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2603.0M382](/packages/ssch-typo3-rector)[odan/phinx-migrations-generator

Migration generator for Phinx

233889.6k24](/packages/odan-phinx-migrations-generator)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

244207.7k2](/packages/dragon-code-laravel-deploy-operations)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

166219.6k1](/packages/cybercog-laravel-clickhouse)

PHPackages © 2026

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