diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a80acb..4c359bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## [1.2.1] +* removed use swoole PDOConfig OR mysql_pdo +* fix bug hostname in database config + ## [1.2.0] * use swoole PDOConfig OR mysql_pdo diff --git a/composer.json b/composer.json index 969f2b4..48c5879 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "flux-eco/storage", "description": "Handling mysql databases with json based table schemas", - "version": "1.2.0", + "version": "1.2.1", "keywords": [ "flux-eco", "storage", @@ -27,7 +27,8 @@ "ext-yaml": "*", "flux-eco/dot-env": ">=0.0.1", "laminas/laminas-code": ">=4.4", - "laminas/laminas-db": ">=2.12" + "laminas/laminas-db": ">=2.12", + "ext-pdo": "*" }, "require-dev": { }, diff --git a/composer.lock b/composer.lock index b87460a..53cb29b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e28ebc5c71c4bff15d5da8a9707b0272", + "content-hash": "5f890f1e8017f56cbf98af87e7bc49cf", "packages": [ { "name": "flux-eco/dot-env", diff --git a/src/Adapters/Config.php b/src/Adapters/Config.php index 82908fd..2613da6 100644 --- a/src/Adapters/Config.php +++ b/src/Adapters/Config.php @@ -31,28 +31,13 @@ public static function newFromEnv(string $tableName, array $jsonSchema, string $ { $apiEnv = Env::new($envPrefix); - if(class_exists('PDOConfig')) { - $databaseConfig = (new PDOConfig()) - ->withHost( $apiEnv->getHost()) - ->withPort(3306) - // ->withUnixSocket('/tmp/mysql.sock') - ->withDbName($apiEnv->getName()) - ->withCharset('utf8mb4') - ->withUsername($apiEnv->getUser()) - ->withPassword($apiEnv->getPassword()); - } else { - $databaseConfig = Adapters\MySqlDatabase\DatabaseConfig::new( - $apiEnv->getHost(), - $apiEnv->getDriver(), - $apiEnv->getName(), - $apiEnv->getUser(), - $apiEnv->getPassword() - ); - } - - - - + $databaseConfig = Adapters\MySqlDatabase\DatabaseConfig::new( + $apiEnv->getHost(), + $apiEnv->getDriver(), + $apiEnv->getName(), + $apiEnv->getUser(), + $apiEnv->getPassword() + ); $databaseClient = Adapters\MySqlDatabase\MysqlDatabaseClient::new( diff --git a/src/Adapters/MySqlDatabase/DatabaseConfig.php b/src/Adapters/MySqlDatabase/DatabaseConfig.php index 23e5f0f..ae0a2de 100644 --- a/src/Adapters/MySqlDatabase/DatabaseConfig.php +++ b/src/Adapters/MySqlDatabase/DatabaseConfig.php @@ -8,20 +8,20 @@ class DatabaseConfig implements Ports\Database\DatabaseConfig { - private string $host; + private string $hostname; private string $driver; private string $database; private string $password; private string $username; private function __construct( - string $host, + string $hostname, string $driver, string $database, string $username, string $password ) { - $this->host = $host; + $this->hostname = $hostname; $this->driver = $driver; $this->database = $database; $this->username = $username; @@ -29,7 +29,7 @@ private function __construct( } public static function new( - string $host, + string $hostname, string $driver, string $database, string $username, @@ -37,7 +37,7 @@ public static function new( ) : self { return new self( - $host, + $hostname, $driver, $database, $username, @@ -45,11 +45,6 @@ public static function new( ); } - final public function getDbName() : string - { - return $this->database; - } - final public function getDatabase() : string { return $this->database; @@ -60,9 +55,9 @@ final public function getDriver() : string return $this->driver; } - final public function getHost() : string + final public function getHostname() : string { - return $this->host; + return $this->hostname; } final public function getPassword() : string diff --git a/src/Adapters/MySqlDatabase/MysqlDatabaseClient.php b/src/Adapters/MySqlDatabase/MysqlDatabaseClient.php index b012281..2cbe697 100644 --- a/src/Adapters/MySqlDatabase/MysqlDatabaseClient.php +++ b/src/Adapters/MySqlDatabase/MysqlDatabaseClient.php @@ -19,13 +19,13 @@ class MysqlDatabaseClient implements Ports\Database\DatabaseClient { protected static array $instances = []; - private DatabaseConfig|PDOConfig $databaseConfig; + private DatabaseConfig $databaseConfig; private Adapter $dbAdapter; private Sql $sql; private TableGateway $tableGateway; private array $jsonSchema; - private function __construct(DatabaseConfig|PDOConfig $databaseConfig, Adapter $dbAdapter, Sql $sql, TableGateway $tableGateway, array $jsonSchema) + private function __construct(DatabaseConfig $databaseConfig, Adapter $dbAdapter, Sql $sql, TableGateway $tableGateway, array $jsonSchema) { $this->databaseConfig = $databaseConfig; $this->dbAdapter = $dbAdapter; @@ -37,7 +37,7 @@ private function __construct(DatabaseConfig|PDOConfig $databaseConfig, Adapter $ public static function new( string $tableName, array $jsonSchema, - DatabaseConfig|PDOConfig $databaseConfig + DatabaseConfig $databaseConfig ): self { $databaseName = $databaseConfig->getDbname(); diff --git a/src/Core/Ports/Database/DatabaseConfig.php b/src/Core/Ports/Database/DatabaseConfig.php index 53bd803..e9c400c 100644 --- a/src/Core/Ports/Database/DatabaseConfig.php +++ b/src/Core/Ports/Database/DatabaseConfig.php @@ -8,7 +8,7 @@ public function getDatabase() : string; public function getDriver() : string; - public function getHost() : string; + public function getHostName() : string; public function getPassword() : string;