modified 初始化安装脚本

This commit is contained in:
zhaoxiang 2019-05-14 00:30:34 +08:00
parent 2f10ae9bac
commit a842c3fc41

View File

@ -0,0 +1,44 @@
<?php
namespace app\command;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
use think\Db;
class Install extends Command {
protected function configure() {
// 指令配置
$this->setName('apiadmin:install')
->addOption('db', null, Option::VALUE_REQUIRED, '数据库连接参数,格式为:数据库类型://用户名:密码@数据库地址:数据库端口/数据库名#字符集')
->addOption('username', null, Option::VALUE_REQUIRED, '超管账号名', 'root')
->addOption('password', null, Option::VALUE_REQUIRED, '超管账号密码', '123456')
->setDescription('ApiAdmin安装脚本');
}
/**
* @param Input $input
* @param Output $output
* @return int|void|null
* @throws \think\Exception
* @author zhaoxiang <zhaoxiang051405@gmail.com>
*/
protected function execute(Input $input, Output $output) {
if ($input->hasOption('db')) {
$conn = Db::connect($input->getOption('db'))->table('admin_user');
try {
$conn->insert([
]);
} catch (\Exception $e) {
echo 123123;
}
} else {
$output->highlight("请输入数据库配置");
}
}
}