修复重复env导致安装失败
This commit is contained in:
parent
e61f3a4115
commit
8d10baa35f
@ -154,8 +154,13 @@ class InstallProjectCommand extends Command
|
|||||||
*/
|
*/
|
||||||
protected function secondStep(): void
|
protected function secondStep(): void
|
||||||
{
|
{
|
||||||
if (file_exists(root_path() . '.env')) {
|
if (file_exists($this->getEnvFilePath())) {
|
||||||
$connections = \config('database.connections');
|
$connections = \config('database.connections');
|
||||||
|
// 因为 env file 导致安装失败
|
||||||
|
if (!$this->databaseLink) {
|
||||||
|
unlink($this->getEnvFilePath());
|
||||||
|
$this->execute($this->input, $this->output);
|
||||||
|
}
|
||||||
|
|
||||||
[
|
[
|
||||||
$connections['mysql']['hostname'],
|
$connections['mysql']['hostname'],
|
||||||
@ -165,7 +170,9 @@ class InstallProjectCommand extends Command
|
|||||||
$connections['mysql']['hostport'],
|
$connections['mysql']['hostport'],
|
||||||
$connections['mysql']['charset'],
|
$connections['mysql']['charset'],
|
||||||
$connections['mysql']['prefix'],
|
$connections['mysql']['prefix'],
|
||||||
] = $this->databaseLink;
|
] = $this->databaseLink ? : [
|
||||||
|
env('mysql.hostname')
|
||||||
|
];
|
||||||
|
|
||||||
\config([
|
\config([
|
||||||
'connections' => $connections,
|
'connections' => $connections,
|
||||||
@ -283,7 +290,6 @@ class InstallProjectCommand extends Command
|
|||||||
$this->output->warning(sprintf('create database %s failed,you need create database first by yourself', $database));
|
$this->output->warning(sprintf('create database %s failed,you need create database first by yourself', $database));
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
unlink(root_path() . '.env');
|
|
||||||
$this->output->error($e->getMessage());
|
$this->output->error($e->getMessage());
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -334,4 +340,15 @@ class InstallProjectCommand extends Command
|
|||||||
$this->migrateAndSeeds();
|
$this->migrateAndSeeds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 env path
|
||||||
|
*
|
||||||
|
* @time 2020年04月06日
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getEnvFilePath()
|
||||||
|
{
|
||||||
|
return root_path() . '.env';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user