国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

二進(jìn)制打包后使用數(shù)據(jù)庫(kù)遷移工具phinx

sdffghy

數(shù)據(jù)庫(kù)遷移工具phinx的使用和安裝,請(qǐng)參考官方文檔:http://m.wtbis.cn/doc/webman/db/migration.html

  1. 打開(kāi)根目錄的webman文件

  2. $cli->run();之前增加如下代碼 :

$phinxApp = new PhinxApplication();
$prefix = "phinx:";
foreach ($phinxApp->all() as $command) {
    $command->setName($prefix . $command->getName());
    // 將 Phinx 的每個(gè)命令添加到 Symfony Console 應(yīng)用程序中
    $cli->add($command);
}

附上完整代碼:

#!/usr/bin/env php
<?php

use Phinx\Console\PhinxApplication;
use Webman\Config;
use Webman\Console\Command;
use Webman\Console\Util;
use support\Container;

require_once __DIR__ . '/vendor/autoload.php';

if (!in_array($argv[1] ?? '', ['start', 'restart', 'stop', 'status', 'reload', 'connections'])) {
    require_once __DIR__ . '/support/bootstrap.php';
} else {
    if (class_exists('Support\App')) {
        Support\App::loadAllConfig(['route']);
    } else {
        Config::reload(config_path(), ['route', 'container']);
    }
}

$cli = new Command();
$cli->setName('webman cli');
$cli->installInternalCommands();
if (is_dir($command_path = Util::guessPath(app_path(), '/command', true))) {
    $cli->installCommands($command_path);
}

foreach (config('plugin', []) as $firm => $projects) {
    if (isset($projects['app'])) {
        if ($command_str = Util::guessPath(base_path() . "/plugin/$firm", 'command')) {
            $command_path = base_path() . "/plugin/$firm/$command_str";
            $cli->installCommands($command_path, "plugin\\$firm\\$command_str");
        }
    }
    foreach ($projects as $name => $project) {
        if (!is_array($project)) {
            continue;
        }
        foreach ($project['command'] ?? [] as $command) {
            $cli->add(Container::get($command));
        }
    }
}

$phinxApp = new PhinxApplication();
$prefix = "phinx:";
foreach ($phinxApp->all() as $command) {
    $command->setName($prefix . $command->getName());
    // 將 Phinx 的每個(gè)命令添加到 Symfony Console 應(yīng)用程序中
    $cli->add($command);
}

$cli->run();

使用方法

只需在原有的phinx命令前加上前綴phinx:即可。

例如:vendor/bin/phinx init 變成:php webman phinx:init

使用phar運(yùn)行: php webman.phar phinx:init

二進(jìn)制運(yùn)行: ./webman.bin phinx:init

20230901補(bǔ)充

  1. 命令確實(shí)可執(zhí)行,但發(fā)現(xiàn)有個(gè)問(wèn)題,在打包后運(yùn)行,提示沒(méi)有配置文件,在根目錄創(chuàng)建后,發(fā)現(xiàn)無(wú)法讀取到遷移記錄。

解決方案:

  1. 在根目錄創(chuàng)建phinx.php或yml配置文件
  2. db/migrations放在打包文件的同級(jí)目錄,執(zhí)行 ./webman.bin phinx:status 查看效果
  3. 自定義二進(jìn)制打包:http://m.wtbis.cn/a/1565 在打包過(guò)程自動(dòng)完成拷貝目錄。
1462 0 1
0個(gè)評(píng)論

sdffghy

330
積分
0
獲贊數(shù)
0
粉絲數(shù)
2023-08-25 加入
??