Skip to content

Commit

Permalink
update a few env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 2, 2020
1 parent bf3a17e commit 562650d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

if ($this->runCommands($commands, $input, $output)->isSuccessful()) {
$output->writeln('<comment>Application ready! Build something amazing.</comment>');
$this->replaceInFile(
'APP_URL=http://localhost',
'APP_URL=http://'.$name.'.test',
$directory.'/.env'
);

$this->replaceInFile(
'DB_DATABASE=laravel',
'DB_DATABASE='.str_replace('-', '_', strtolower($name)),
$directory.'/.env'
);

$output->writeln(PHP_EOL.'<comment>Application ready! Build something amazing.</comment>');
}

return 0;
Expand Down Expand Up @@ -159,4 +171,12 @@ protected function runCommands($commands, InputInterface $input, OutputInterface

return $process;
}

protected function replaceInFile($search, $replace, $file)
{
file_put_contents(
$file,
str_replace($search, $replace, file_get_contents($file))
);
}
}

0 comments on commit 562650d

Please sign in to comment.