Download the PHP package comphp/database without Composer
On this page you can find all versions of the php package comphp/database. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package database
comphp/database
The comphp/database library provides a flexible, modular, and extensible way to manage database connections and execute queries in PHP. Designed to integrate seamlessly with the rest of the CommonPHP ecosystem, it supports:
- Multiple connections and drivers
- Alias-based connections
- Query profiling
- Event-dispatching for database operations
- PSR-3 logging
- Extensibility through the comphp/extensible library
Features
- Connection Management – Centrally manage different database connections (e.g., MySQL, alias drivers, custom drivers, etc.).
- Extensible Drivers – Register new drivers via attributes to easily expand your supported databases.
- Query Execution – Execute queries with structured methods to fetch single rows, multiple rows, or scalars.
- Transaction Handling – Built-in methods for wrapping multiple queries in a transaction.
- PSR-14 Events – Emit events (
ConnectedEvent
,QueryExecutedEvent
) for deeper integration. - Profiling & Logging – Enable query profiling and leverage PSR-3 for structured logs.
Installation
Install via Composer:
Getting Started
Below is a basic example using DatabaseManager:
Examples
See examples/ for usage demos:
- basic-usage.php – Initializing a connection and querying.
- transaction-usage.php – Wrapping multiple queries in transactions.
- alias-driver-usage.php – Creating an alias-based driver.
- query-profiling.php – Enabling profiling and listening to
QueryExecutedEvent
. - error-handling.php – Handling exceptions gracefully.
Usage
Connecting to Multiple Databases
Transactions
Profiling
Driver Extensibility
comphp/database
integrates with comphp/extensible. To create your own driver:
Testing
-
Install dev dependencies (including PHPUnit):
- Run tests:
Check out test/ for unit tests that demonstrate usage.
Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
License
This project is released under the MIT License. See LICENSE.md for details.
All versions of database with dependencies
psr/log Version ^3.0
comphp/extensible Version ^0.1
comphp/events Version ^0.2
ext-pdo Version *