gatovel / database
Database module for Gatovel Framework
Requires
- php: ^8.3
This package is not auto-updated.
Last update: 2026-09-03 03:54:43 UTC
README
Database module for the Gatovel Framework.
Overview
Gatovel Database is an independent database module designed to provide database functionality without coupling it directly to the Gatovel Framework core.
It provides a simple and extensible API for working with databases, including connections, queries, transactions, migrations, and schema management.
Features
-
Database connections
-
Query Builder
-
Transactions
-
Migrations
-
Migration rollback
-
Schema management
-
Database grammars
- MySQL
- PostgreSQL
- SQLite
-
PDO-based database access
-
Framework-independent architecture
Requirements
- PHP 8.3+
- PDO
- PDO driver for the database being used
Installation
Install the package using Composer:
composer require gatovel/database
Basic Usage
Connect to a database:
use Gatovel\Database\Database; Database::connect([ 'connection' => 'mysql', 'host' => 'localhost', 'port' => 3306, 'database' => 'example', 'username' => 'root', 'password' => 'password', ]);
Query Builder
$users = Database::table('users') ->get();
Transactions
$transaction = Database::transaction(); $transaction->begin(); try { // Database operations $transaction->commit(); } catch (\Throwable $e) { $transaction->rollback(); throw $e; }
Schema
$schema = Database::schema();
Migrations
Migrations can be executed through the MigrationRunner:
use Gatovel\Database\migration\MigrationRunner; $runner = new MigrationRunner(); $runner->migrate(__DIR__ . '/migration');
Rollback the last migration batch:
$runner->rollbackLastBatch( __DIR__ . '/migration' );
Architecture
The module is intentionally separated from the Gatovel Framework core.
Gatovel Framework
│
├── Gatovel CLI
│
└── Gatovel Database
│
├── Connection
├── Query Builder
├── Transactions
├── Migrations
├── Schema
└── Grammars
This architecture allows the database module to evolve independently and potentially be reused by other applications or projects.
License
This project is licensed under the MIT License.