Skip to content

Commit d9ee774

Browse files
committed
Allow database port definitions in config-userfrosting.php
1 parent b71e818 commit d9ee774

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Fixed some minor error screen layout issues
66
- Make User::fresh() compatible with Eloquent\Model v5.2.40+
77
- Update composer require to allow for Fortress 1.x bugfixes
8+
- Allow database port definitions in config-userfrosting.php
89

910
## v0.3.1.18
1011

userfrosting/config-userfrosting-example.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
],
4242
'db' => [
4343
'db_host' => 'localhost',
44+
'db_port' => '', // Leave blank to use the default port for your database driver (eg. 3306 for MySQL)
4445
'db_name' => 'userfrosting',
4546
'db_user' => 'admin',
4647
'db_pass' => 'password',
@@ -90,6 +91,7 @@
9091
],
9192
'db' => [
9293
'db_host' => 'localhost',
94+
'db_port' => '', // Leave blank to use the default port for your database driver (eg. 3306 for MySQL)
9395
'db_name' => 'userfrosting',
9496
'db_user' => 'admin',
9597
'db_pass' => 'password',

userfrosting/initialize.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
$dbx = $app->config('db');
4242

43-
$capsule->addConnection([
43+
$connection_array = [
4444
'driver' => 'mysql',
4545
'host' => $dbx['db_host'],
4646
'database' => $dbx['db_name'],
@@ -49,7 +49,15 @@
4949
'charset' => 'utf8',
5050
'collation' => 'utf8_unicode_ci',
5151
'prefix' => ''
52-
]);
52+
];
53+
54+
// This is for backwards compatibility. Pre-0.3.1.19 configuration files won't have $dbx['db_port'] defined at all.
55+
if (isset($dbx['db_port']))
56+
{
57+
$connection_array['port'] = $dbx['db_port'];
58+
}
59+
60+
$capsule->addConnection($connection_array);
5361

5462
// Register as global connection
5563
$capsule->setAsGlobal();

0 commit comments

Comments
 (0)