[web-master] main: Allow port to be configured through environment seting

From: Date: Mon, 26 Aug 2024 23:42:16 +0000
Subject: [web-master] main: Allow port to be configured through environment seting
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-32016@lists.php.net to get a copy of this message
Author: Derick Rethans (derickr) Date: 2024-08-26T09:53:10+01:00 Commit: https://github.com/php/web-master/commit/46bf69f2c58be3ce3f31efbdeebc0d7820de45ec Raw diff: https://github.com/php/web-master/commit/46bf69f2c58be3ce3f31efbdeebc0d7820de45ec.diff Allow port to be configured through environment seting Changed paths: M src/DB.php Diff: diff --git a/src/DB.php b/src/DB.php index 770c85f..e9338fa 100644 --- a/src/DB.php +++ b/src/DB.php @@ -8,7 +8,7 @@ final class DB extends PDO { public static function connect(): self { - $connectionConfig = 'mysql:host=' . self::getHost() . ';dbname=' . self::getDatabase(); + $connectionConfig = 'mysql:host=' . self::getHost() . ';port=' . self::getPort() . ';dbname=' . self::getDatabase(); $db = new self($connectionConfig, self::getUser(), self::getPassword()); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -22,6 +22,11 @@ public static function getHost(): string return \getenv("DATABASE_HOST") ?: "localhost"; } + public static function getPort(): string + { + return \getenv("DATABASE_PORT") ?: "3306"; + } + public static function getUser(): string { return \getenv("DATABASE_USER") ?: "nobody";

« previous php.webmaster (#32016) next »