PHP code example of purocean / php-db-migration

1. Go to this page and download the library: Download purocean/php-db-migration library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

purocean / php-db-migration example snippets


// migration.php
date_default_timezone_set('PRC');
$migrationConfig = [
    'tablePrefix' => 'test_prefix_', // 表前缀
    'migrationsPath' => __DIR__.'/migrations', // 迁移储存位置
    'dbConfig' => [ // 数据库配置
        'username' => 'root',
        'password' => '',
        'dsn' => 'mysql:host=localhost;port=3306;dbname=db_migration_test;charset=utf8',
    ]
];

(new \DbMigration\Cli($migrationConfig))->run();

bash
php migration.php help
bash
cd test
vim config.php # 修改数据库配置
php test.php