Skip to main content

Installation

Install the package with Composer:

composer require dirthara/database

Requirements

RequirementVersion
PHP8.5 or newer
ext-pdoRequired

Driver extensions

PDO itself is the shared interface; each database needs its own PDO driver extension. Install only the ones you connect to.

DatabaseExtensionDriverName
MySQL and MariaDBpdo_mysqlDriverName::MySql
PostgreSQLpdo_pgsqlDriverName::PostgresSql
SQLitepdo_sqliteDriverName::SQLite
SQL Serverpdo_sqlsrvDriverName::SqlServer

Check what your runtime has:

php -r 'print_r(PDO::getAvailableDrivers());'

A missing extension is not reported when you register the driver. It surfaces as a ConnectionException the first time a query runs, because that is when PDO is constructed.

Autoloading

The package autoloads Dirthara\Database\ from src/ under PSR-4. Everything in these docs is imported from that namespace, for example:

use Dirthara\Database\Connection\ConnectionManager;
use Dirthara\Database\Connection\Driver\DriverName;
use Dirthara\Database\Connection\ValueObjects\ConnectionConfig;