Skip to content

Commit

Permalink
Replace DB_PORT and DB_CONNECTION for pgsql (#63)
Browse files Browse the repository at this point in the history
* Replace DB_PORT and DB_CONNECTION for pgsql

* Update InstallCommand.php

* Update InstallCommand.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
nguyenyou and taylorotwell authored Mar 3, 2021
1 parent 67b76f4 commit 3e6972c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,14 @@ protected function replaceEnvVariables(array $services)
{
$environment = file_get_contents($this->laravel->basePath('.env'));

$host = in_array('pgsql', $services) ? 'pgsql' : 'mysql';

$environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=$host", $environment);
if (in_array('pgsql', $services)) {
$environment = str_replace('DB_CONNECTION=mysql', "DB_CONNECTION=pgsql", $environment);
$environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=pgsql", $environment);
$environment = str_replace('DB_PORT=3306', "DB_PORT=5432", $environment);
} else {
$environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=mysql", $environment);
}

$environment = str_replace('MEMCACHED_HOST=127.0.0.1', 'MEMCACHED_HOST=memcached', $environment);
$environment = str_replace('REDIS_HOST=127.0.0.1', 'REDIS_HOST=redis', $environment);

Expand Down

0 comments on commit 3e6972c

Please sign in to comment.