parent
6ef9bb4805
commit
1e7fa2d894
@ -1,9 +1,15 @@ |
|||||||
{ |
{ |
||||||
|
"config": { |
||||||
|
"platform": { |
||||||
|
"php": "8.4" |
||||||
|
} |
||||||
|
}, |
||||||
"require": { |
"require": { |
||||||
"twig/twig": "^3.0", |
"twig/twig": "^3.0", |
||||||
"liquid/liquid": "^1.4", |
"liquid/liquid": "^1.4", |
||||||
"ezyang/htmlpurifier": "^4.18", |
"ezyang/htmlpurifier": "^4.18", |
||||||
"twilio/sdk": "^8.7", |
"twilio/sdk": "^8.7", |
||||||
"firebase/php-jwt": "^6.11" |
"firebase/php-jwt": "^6.11", |
||||||
|
"vlucas/phpdotenv": "^5.6" |
||||||
} |
} |
||||||
} |
} |
||||||
|
|||||||
@ -0,0 +1,43 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Robert Strutts <Bob_586@Yahoo.com> |
||||||
|
* @copyright (c) 2025, Robert Strutts |
||||||
|
* @license MIT |
||||||
|
*/ |
||||||
|
|
||||||
|
class Database |
||||||
|
{ |
||||||
|
public function __construct(private string $host, |
||||||
|
private string $name, |
||||||
|
private string $user, |
||||||
|
private string $password) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public function getConnection(): PDO |
||||||
|
{ |
||||||
|
$dsn = "mysql:host={$this->host};dbname={$this->name}"; |
||||||
|
|
||||||
|
return new PDO($dsn, $this->user, $this->password); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class Repository |
||||||
|
{ |
||||||
|
public function __construct(private Database $database) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public function getAll(): array |
||||||
|
{ |
||||||
|
$pdo = $this->database->getConnection(); |
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT * FROM tblproduct"); |
||||||
|
|
||||||
|
return $stmt->fetchAll(PDO::FETCH_ASSOC); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
@ -0,0 +1,21 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Robert Strutts <Bob_586@Yahoo.com> |
||||||
|
* @copyright (c) 2025, Robert Strutts |
||||||
|
* @license MIT |
||||||
|
*/ |
||||||
|
|
||||||
|
use CodeHydrater\bootstrap\registry as Reg; |
||||||
|
|
||||||
|
Reg::get('di')->register('dotenv', function() { |
||||||
|
if (! Reg::get('loader')->is_loaded('Dotenv')) { |
||||||
|
Reg::get('loader')->add_namespace("Dotenv", CodeHydrater_PROJECT. "/vendor/vlucas/phpdotenv/src"); |
||||||
|
|
||||||
|
Reg::get('loader')->add_namespace("PhpOption", CodeHydrater_PROJECT. "/vendor/phpoption/phpoption/src/PhpOption"); |
||||||
|
|
||||||
|
Reg::get('loader')->add_namespace("GrahamCampbell\\ResultType", CodeHydrater_PROJECT."/vendor/graham-campbell/result-type/src"); |
||||||
|
} |
||||||
|
}); |
||||||
Loading…
Reference in new issue