Skip to content

Commit

Permalink
Fixed undefined array key mariadb10|11 error on installation. (#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
kursatcanciger authored Jul 1, 2024
1 parent 481a448 commit 8ba049b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Console/Concerns/InteractsWithDockerComposeServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,25 @@ protected function buildDockerCompose(array $services)
->all();
}

// Update the dependencies if the MariaDB service is used...
if (in_array('mariadb10', $services) || in_array('mariadb11', $services)) {
$compose['services']['laravel.test']['depends_on'] = array_map(function ($dependedItem) {
if (in_array($dependedItem, ['mariadb10', 'mariadb11'])) {
return 'mariadb';
}

return $dependedItem;
}, $compose['services']['laravel.test']['depends_on']);
}

// Add the services to the docker-compose.yml...
collect($services)
->filter(function ($service) use ($compose) {
return ! array_key_exists($service, $compose['services'] ?? []);
})->each(function ($service) use (&$compose) {
$compose['services'][$service] = Yaml::parseFile(__DIR__ . "/../../../stubs/{$service}.stub")[$service];
in_array($service, ['mariadb10', 'mariadb11'])
? $compose['services']['mariadb'] = Yaml::parseFile(__DIR__ . "/../../../stubs/{$service}.stub")['mariadb']
: $compose['services'][$service] = Yaml::parseFile(__DIR__ . "/../../../stubs/{$service}.stub")[$service];
});

// Merge volumes...
Expand All @@ -97,6 +110,10 @@ protected function buildDockerCompose(array $services)
})->filter(function ($service) use ($compose) {
return ! array_key_exists($service, $compose['volumes'] ?? []);
})->each(function ($service) use (&$compose) {
if (in_array($service, ['mariadb10', 'mariadb11'])) {
$service = 'mariadb';
}

$compose['volumes']["sail-{$service}"] = ['driver' => 'local'];
});

Expand Down

0 comments on commit 8ba049b

Please sign in to comment.