承接 wijoc/mi-grator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wijoc/mi-grator

最新稳定版本:0.1.0

Composer 安装命令:

composer require wijoc/mi-grator

包简介

A stand alone database migration for PHP and Wordpress.

README 文档

README

Extra Package PHP Database Migration that is compatible with procedural PHP and WordPress. This project provides a database migration specifically for WordPress projects. Heavily influenced by Laravel and/or Symfony migration and inspired by CakePHP/Phinx cakephp/phinx, this project originated from a personal need and is still in beta development. All inputs are highly appreciated.

📦 Features

  • Create, Migrate and rollback migration
  • PHP CLI support (vendor/bin/mi-grator)
  • Native WordPress CLI (wp mi-grator) support
  • Supported commands to make migration, migrate new migration, and/or reset migration

🧩 Dependencies

  • PHP 7.4+ or 8.x
  • Composer (for autoloading)
  • Symfony Consolesymfony/console (for cli command)
  • PHP dotenvvlucas/phpdotenv (for loading .env file)
  • WP-CLI (for WordPress command-line integration)
  • WordPress (optional, only for WP CLI support)

Autoloading and command registration are handled automatically via Composer.

📁 Project Directory Structure (after installation directories)

your-project
├── migrations/
│ ├── 2025_08_07_000000_create_user_table.php
│ └── 2025_08_07_000000_create_user_detail_table.php
├── vendor/
│ ├── wijoc/mi-grator
│ │ ├── Commands
│ │ └── Migrations
| ├── Kernel.php
│ └── QueryBuilder.php

🧰 Requirements

  • WordPress 6.2+
  • PHP 8.0+

🚧 Installation

  1. You can install the library via Composer:
composer  require  wijoc/mi-grator

or copy from this repository and move it to your project directory

git clone git@github.com:wijoc/validify-mi.git
mv wijoc/mi-grator /project-dir
  1. Set env or constant for migration table name and migration path
DB_HOST={your_databe_host}
DB_USER={your_databe_username}
DB_PASSWORD={your_databe_password}
DB_NAME={your_databe_name}

MIGRATION_TABLE={your_migration_table_name} # By default this will set to 'migration'
MIGRATION_FILE_PATH={your_migration_table_name} # By default this will set to directory ./migrations

Usage

💻 In Plain PHP (non-WordPress)

Use the CLI binary provided:

./vendor/bin/mygrator make:migration create_users_table --table=users
./vendor/bin/mygrator migrate
./vendor/bin/mygrator migrate:fresh
./vendor/bin/mygrator migrate:rollback
./vendor/bin/mygrator migrate:reset

You can include these in your deployment scripts, CI/CD pipelines, or setup scripts.

🧩 In WordPress (via WP-CLI)

If you're using WordPress and WP-CLI, and your theme/plugin loads vendor/autoload.php, you're ready to go:

wp mi-grator make:migration create_users_table --table=users
wp mi-grator migrate
wp mi-grator migrate:rollback

⚠️ Ensure your theme or plugin loads Composer autoloader:

require_once **DIR** . '/vendor/autoload.php';

You can also use a must-use plugin (mu-plugin) to include the autoloader automatically if you're building a distributable plugin.

📃 License

MIT License

🤝 Contributions

Pull requests are welcome! If you find a bug or have a feature request, feel free to open an issue.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-07