Skip to content

Commit 18101b3

Browse files
Jubekitaylorotwell
andauthored
Add mariadb installation option (#292)
* Add MariaDB installation option * Temporary use the Slim Skeleton Branch * revert to master branch * Update NewCommand.php * Update NewCommand.php * Update NewCommand.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 18c134c commit 18101b3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/NewCommand.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ protected function defaultBranch()
233233
*/
234234
protected function configureDefaultDatabaseConnection(string $directory, string $database, string $name)
235235
{
236+
// MariaDB configuration only exists as of Laravel 11...
237+
if ($database === 'mariadb' && ! $this->hasMariaDBConfig($directory)) {
238+
$database = 'mysql';
239+
}
240+
236241
$this->replaceInFile(
237242
'DB_CONNECTION=mysql',
238243
'DB_CONNECTION='.$database,
@@ -297,6 +302,25 @@ protected function configureDefaultDatabaseConnection(string $directory, string
297302
);
298303
}
299304

305+
/**
306+
* Determine if the application has a MariaDB configuration entry.
307+
*
308+
* @param string $directory
309+
* @return bool
310+
*/
311+
protected function hasMariaDBConfig(string $directory): bool
312+
{
313+
// Laravel 11+ has moved the configuration files into the framework...
314+
if (! file_exists($directory.'/config/database.php')) {
315+
return true;
316+
}
317+
318+
return str_contains(
319+
file_get_contents($directory.'/config/database.php'),
320+
"'mariadb' =>"
321+
);
322+
}
323+
300324
/**
301325
* Install Laravel Breeze into the application.
302326
*
@@ -368,6 +392,7 @@ protected function promptForDatabaseOptions(InputInterface $input)
368392
label: 'Which database will your application use?',
369393
options: [
370394
'mysql' => 'MySQL',
395+
'mariadb' => 'MariaDB',
371396
'pgsql' => 'PostgreSQL',
372397
'sqlite' => 'SQLite',
373398
'sqlsrv' => 'SQL Server',

0 commit comments

Comments
 (0)