定制 regur/lmvc-database-migration 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

regur/lmvc-database-migration

最新稳定版本:v1.0.0

Composer 安装命令:

composer require regur/lmvc-database-migration

包简介

A lightweight database migration system for LMVC-based PHP applications.

README 文档

README

Regur Technology Solutions

Regur Technology Solutions - LMVC DB Migration Library

A simple database migration package for PHP applications, inspired by Laravel's Artisan.

📌 Features

  • Create and manage database migrations
  • CLI command similar to Laravel Artisan
  • Auto-generates migration files
  • Supports custom database schemas

🚀 Installation

Install via Composer:

composer require regur/lmvc-database-migration

After installation, the CLI command will be available at:

php lmvcdb

Important - the .env file is also needed for database credentials

below of lmvcdb file (same like atrisan file)

<?php

namespace Regur\LMVC\Framework\Bin;

require './vendor/autoload.php';

use Regur\LMVC\Framework\Database\Bootstrap;
use Regur\LMVC\Framework\Database\Libs\Dotenv;

$dotenv = Dotenv::createImmutable(getcwd());
$dotenv->load();

$dbcred = [
    'host' => $_ENV['DB_HOST'],
    'driver'=> $_ENV['DB_DRIVER'],
    'database' => $_ENV['DB_NAME'],
    'username' => $_ENV['DB_UNAME'],
    'password' => $_ENV['DB_PWD'],
    'port' => $_ENV['DB_PORT']
];

Bootstrap::init($dbcred);

?>

Now you can run:

php lmvcdb migrate

🛠 Usage

Create a New Migration

php lmvcdb make:migration create_users_table

This will generate a migration file inside database/migrations.

Run Migrations

php lmvcdb migrate

Applies all pending migrations.

Fresh Migrations (Reset & Run All)

php lmvcdb migrate:fresh

Drops all tables and runs migrations from scratch.

Apply Pending Migrations

php lmvcdb migrate:up

Runs the next batch of pending migrations.

Rollback the Last Migration Batch

php lmvcdb migrate:down

Rolls back the last executed migration batch.

Refresh Migrations (Rollback & Reapply)

php lmvcdb migrate:refresh

Rolls back all migrations and runs them again.

Make Seeder

php lmvcdb make:seeder UsersSeeder

It will create new seeder

Run all seeders

php lmvcdb seed

It will run all seeders at once

Run specific seeder

php lmvcdb seed --class=UsersSeeder

It will run specific seeder

📂 Project Structure

lmvc-database-migration/
│── src/
│   ├── Database/
│   │   ├── Core/                                # Core migration classes
│   │   │   ├── Migration.php
│   │   │   ├── Schema.php
│   │   │   ├── Blueprint.php
│   │   │   ├── DB.php
│   │   ├── Libs/                                # Relevent custom libraries
│   │   │   ├── Dotenv.php
│   ├── Composer/
│   │   ├── Installer.php                        # This will create a file lmvc at root of your project
│   ├── Cli/                                     # This contains commands registered in symfony CLI
│   │   ├── InstallCommand.php                   # php vendor/cli/lmvcdb install 
│   │   ├── MakeMigrationCommand.php             # php lmvcdb make:migration <args>
│   │   ├── MakeRawMigrationCommand.php          # php lmvcdb make:raw-migration <args>
│   │   ├── MigrateCommand.php                   # php lmvcdb migrate <args>
│   │   ├── MakeSeederCommand.php                # php lmvcdb make:seeder <args>
│   │   ├── SeedCommand.php                      # php lmvcdb seed <args>
│   ├── Bootstrap.php                            # Main bootstrap file
│── bin/
│   ├── lmvcdb                                   # CLI command file
│── composer.json                                # Composer JSON file (for versioning and maintaining relevent packages)
│── README.md

🔧 Configuration

Configure the database connection in lmvcdb:

Regur\LMVC\Framework\Database\Bootstrap::init([
    'host' => $_ENV['DB_HOST'],
    'driver'=> $_ENV['DB_DRIVER'],
    'database' => $_ENV['DB_NAME'],
    'username' => $_ENV['DB_UNAME'],
    'password' => $_ENV['DB_PWD'],
    'port' => $_ENV['DB_PORT']
]);

For docker you need to run commands under docker container

docker exec -it pinlocal "your desired command"

📜 License

This package is open-source and available under the MIT License.

💡 Need help? Feel free to create an issue or contribute!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-06