A modern, lightweight, and testable database wrapper for PHP.
PDO4You is designed to simplify PDO usage without the overhead of a full ORM. Built with modern PHP (8.2+), it supports dependency injection, PSR-4 autoloading, and platform-specific database strategies.
To set up the development environment, clone the repository and run:
composer installInstall the package via Composer:
composer require giovanniramos/pdo4youInstantiate the class by injecting your PDO connection and the appropriate platform driver.
use PDO;
use PDO4You\PDO4You;
use PDO4You\Platform\MySqlPlatform;
// 1. Create a native PDO connection
$pdo = new PDO('mysql:host=localhost;dbname=mydb', 'user', 'password');
// 2. Select the platform
$platform = new MySqlPlatform();
// 3. Inject into PDO4You
$db = new PDO4You($pdo, $platform); // SELECT (returns associative array)
$users = $db->select("SELECT * FROM users WHERE status = ?", ['active']);
// EXECUTE (insert, update, delete)
$db->exec("UPDATE users SET status = 'inactive' WHERE id = 1");
// GET LAST ID (using the platform strategy)
$newId = $db->lastId();You can run the test suite using one of the following methods:
If you have Docker installed, run:
docker-compose up --buildIf you have PHP 8.2+ and Composer installed:
composer install
./vendor/bin/phpunit testsMIT