Search by

giovanniramos / pdo4you

giovanniramos

Modern lightweight database wrapper using PDO

Package info

github.com/giovanniramos/PDO4You

pkg:composer/giovanniramos/pdo4you

Statistics

Installs: 116

Dependents: 0

Suggesters: 0

Stars: 72

Open Issues: 5

5.0.0 2026-08-28 23:54 UTC

This package is not auto-updated.

Last update: 2026-09-07 22:58:12 UTC


README

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.

Development

To set up the development environment, clone the repository and run:

composer install

Installation

Install the package via Composer:

composer require giovanniramos/pdo4you

Usage

1. Setup

Instantiate 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);

2. Operations

// SELECT (returns associative array)
$users = $db->select("SELECT * FROM users WHERE status = ?", ['active']);

// EXECUTE (insert, update, delete)
$db->exec("INSERT INTO users (name, surname) VALUES (?, ?)", [['John', 'Doe'], ['Jane', 'Doe']]);

// GET LAST ID (using the platform strategy)
$newId = $db->lastId();

Running Tests

You can run the test suite using one of the following methods:

1. Using Docker (Isolated Environment)

If you have Docker installed, run:

docker-compose up --build

2. Using Command Line (Local Environment)

If you have PHP 8.2+ and Composer installed:

composer install
./vendor/bin/phpunit tests

License

MIT