Skip to content

Commit 8607e58

Browse files
committed
feat: configure new fields in env.development on initialization process
Refs: #42
1 parent eec24b3 commit 8607e58

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/Commands/InitCommand.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,29 @@ public function handle(): void
102102

103103
$envFile = (file_exists('.env')) ? '.env' : '.env.example';
104104

105-
$this->updateEnvFile($envFile, [
105+
$envConfig = [
106106
'APP_NAME' => $this->appName,
107107
'DB_CONNECTION' => $this->dbConnection,
108108
'DB_HOST' => $this->dbHost,
109109
'DB_PORT' => $this->dbPort,
110110
'DB_DATABASE' => $this->dbName,
111111
'DB_USERNAME' => $this->dbUserName,
112112
'DB_PASSWORD' => '',
113-
]);
113+
];
114+
115+
$this->updateEnvFile($envFile, $envConfig);
114116

115117
if (!file_exists('.env.development')) {
116118
copy('.env.example', '.env.development');
117119
}
118120

119121
$this->updateEnvFile('.env.development', [
120-
'APP_NAME' => $this->appName,
121122
'APP_URL' => $this->appUrl,
122123
'APP_MAINTENANCE_DRIVER' => 'cache',
123124
'CACHE_STORE' => 'redis',
124125
'QUEUE_CONNECTION' => 'redis',
125126
'SESSION_DRIVER' => 'redis',
126-
'DB_CONNECTION' => $this->dbConnection,
127+
...$envConfig,
127128
]);
128129

129130
$this->info('Project initialized successfully!');

tests/fixtures/InitCommandTest/env.development_app_name_not_pascal_case.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ APP_LOG_LEVEL=debug
66
APP_URL=https://mysite.com
77

88
DB_CONNECTION=pgsql
9-
DB_HOST=
10-
DB_PORT=
11-
DB_DATABASE=
12-
DB_USERNAME=
9+
DB_HOST=pgsql
10+
DB_PORT=5432
11+
DB_DATABASE=postgres
12+
DB_USERNAME=postgres
1313
DB_PASSWORD=
1414

1515
BROADCAST_DRIVER=log

tests/fixtures/InitCommandTest/env.development_app_name_pascal_case.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ APP_LOG_LEVEL=debug
66
APP_URL=https://mysite.com
77

88
DB_CONNECTION=pgsql
9-
DB_HOST=
10-
DB_PORT=
11-
DB_DATABASE=
12-
DB_USERNAME=
9+
DB_HOST=pgsql
10+
DB_PORT=5432
11+
DB_DATABASE=postgres
12+
DB_USERNAME=postgres
1313
DB_PASSWORD=
1414

1515
BROADCAST_DRIVER=log

0 commit comments

Comments
 (0)