Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mariadb installation option #292

Merged
merged 6 commits into from
Nov 28, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ protected function defaultBranch()
*/
protected function configureDefaultDatabaseConnection(string $directory, string $database, string $name)
{
// MariaDB Configuration only exists as of Laravel 11
if ($database === 'mariadb' && ! $this->hasMariaDBConfig($directory)) {
$database = 'mysql';
}

$this->replaceInFile(
'DB_CONNECTION=mysql',
'DB_CONNECTION='.$database,
Expand Down Expand Up @@ -297,6 +302,26 @@ protected function configureDefaultDatabaseConnection(string $directory, string
);
}

/**
* Determine if the application has a MariaDB configuration.
*
* @param string $directory
* @return bool
*/
protected function hasMariaDBConfig(string $directory): bool
{
// Laravel 11+ has moved the config files into the framework and there exists the mariadb configuration
if (! file_exists($directory.'/config/database.php')) {
return true;
}

// Check if for whatever reasons there exists a mariadb configuration in the database config
return str_contains(
file_get_contents($directory.'/config/database.php'),
"'mariadb' =>"
);
}

/**
* Install Laravel Breeze into the application.
*
Expand Down Expand Up @@ -368,6 +393,7 @@ protected function promptForDatabaseOptions(InputInterface $input)
label: 'Which database will your application use?',
options: [
'mysql' => 'MySQL',
'mariadb' => 'MariaDB',
'pgsql' => 'PostgreSQL',
'sqlite' => 'SQLite',
'sqlsrv' => 'SQL Server',
Expand Down Expand Up @@ -635,7 +661,7 @@ protected function canResolveHostname($hostname)
protected function getVersion(InputInterface $input)
{
if ($input->getOption('dev')) {
return 'dev-master';
return 'dev-slim-skeleton-11.x';
Jubeki marked this conversation as resolved.
Show resolved Hide resolved
}

return '';
Expand Down