yousha / dbalite
A lightweight DBAL(Database Abstraction Layer) library for PHP.
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
pkg:composer/yousha/dbalite
Requires
- php: 8.*
- ext-filter: *
- ext-pdo: *
Requires (Dev)
- ergebnis/composer-normalize: 2.*
- friendsofphp/php-cs-fixer: 3.*
- icanhazstring/composer-unused: 0.*
- maglnet/composer-require-checker: 3.* || 4.*
- overtrue/phplint: 9.*
- phpunit/phpunit: 9.* || 10.* || 11.* || 12.*
- rector/rector: 2.*
- yousha/codecop: 2.*
This package is auto-updated.
Last update: 2025-12-28 13:47:43 UTC
README
A lightweight DBAL(Database Abstraction Layer) library for PHP.
Contents
- Overview
- Features
- Requirements
- Installation
- Configuration
- Usage
- Support
- Changelog
- Contributing
- Code of Conduct
- DCO
- Contributors
- Notice
- License
Overview
DBALite is a powerful yet lightweight Database Abstraction Layer(DBAL) library by DataMapper pattern. It is designed for PHP developers who need a simple, efficient, and secure way to interact with multiple database systems. Built with modern PHP practices in mind, DBALite provides a clean, intuitive API for performing database operations while ensuring security, flexibility, and performance.
Features
- Supports MySQL/MariaDB, OracleDB, and SQLite databases.
- Create tables, add columns, drop tables, manage indexes, and more.
- Retrieve tables, columns, and check column existence.
- Build SQL queries dynamically using a fluent interface.
- Manage database schema changes with migration classes.
- Map database rows to entities and perform CRUD operations.
- Sanitize inputs, validate data, and prevent XSS and SQL injection.
- Begin, commit, or rollback transactions safely.
- Log executed queries for debugging purposes.
- Perform bulk inserts efficiently.
- Secure connections with SSL certificates.
- Merge and extend configuration settings at runtime.
- Supports PHP >= 8.*.
- Supports MySQL/MariaDB(Default), OracleDB, SQLite databases.
- Supports Microsoft Windows, GNU+Linux, Apple MacOS.
Requirements
- PHP >= 8.*
- Composer >= 2
- Database server(MySQL/MariaDB, OracleDB, or SQLite)
Installation
Via Composer:
composer require yousha/dbalite
Configuration
Create a configuration array with your database settings:
$config = [ 'host' => '127.0.0.1', 'dbname' => 'test_database', 'user' => 'test_username', 'password' => 'test_password', 'ssl_ca' => '/path/to/ca-cert.pem', // Optional: Path to SSL CA certificate. 'ssl_verify' => false, // Optional: Disable server cert verification. ];
Or configuration for OracleDB:
$config = [ 'driver' => OracleDriver::class, 'database' => [ 'host' => '127.0.0.1', 'port' => 1521, 'dbname' => 'test_database', 'user' => 'test_username', 'password' => 'test_password', ], ];
Or configuration for SQLite:
$config = [ 'driver' => SQLiteDriver::class, 'database' => [ 'path' => __DIR__ . '/testdatabase.sqlite', ], ];
Initialize Dbal instance:
use Yousha\DBALite\Dbal; use Yousha\DBALite\ConfigManager; $config = new ConfigManager([ 'database' => $config, 'migrations_dir' => __DIR__ . '/migrations', // Optional: Path to migration files. ]); $dbal = new Dbal($config);
Usage
Quick start snippet:
<?php require 'vendor/autoload.php'; use Yousha\DBALite\ConfigManager; use Yousha\DBALite\Dbal; $config = new ConfigManager([ 'driver' => \Yousha\DBALite\Driver\MySQLDriver::class, 'database' => [ 'host' => '127.0.0.1', 'dbname' => 'test', 'user' => 'root', 'password' => '', ], ]); $dbal = new Dbal($config); $result = $dbal->getDriver()->query("SELECT 'Hello, DBALite!' AS message"); print_r($result);
QA/QC
Run tests to ensure everything works as expected:
composer test
Or:
vendor/bin/phpunit tests/
Support
For any question, issues and feature requests, open an issue..
Changelog
See CHANGELOG.txt file.
Contributing
Contributions are welcome! Please follow these steps:
- Fork repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request with a detailed description of your changes.
For more details see CONTRIBUTING.txt.
Code of Conduct
See CODE_OF_CONDUCT.txt file.
DCO
See DCO.txt file.
Contributors
See CONTRIBUTORS.txt file.
Notice
See NOTICE.txt file.
License
This open-source software is distributed under the GPL-3.0 license. See LICENSE file.