Download the PHP package codemonster-ru/database without Composer
On this page you can find all versions of the php package codemonster-ru/database. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codemonster-ru/database
More information about codemonster-ru/database
Files in codemonster-ru/database
Package database
Short Description Lightweight, framework-agnostic database layer with PDO connections, fluent Query Builder, Schema Builder, and full migration system.
License MIT
Homepage https://github.com/codemonster-ru/database
Informations about the package database
codemonster-ru/database
A lightweight, framework-agnostic database layer for PHP.
Part of the Codemonster ecosystem — but works fully standalone.
Installation
Usage
1. Database Manager
You can define multiple connections and select them by name:
- For MySQL/MariaDB use
driver => 'mysql'. - For SQLite use
driver => 'sqlite'and onlydatabaseis required (file path or:memory:). - Other PDO drivers can be wired via
driver+ DSN-compatible options; the query layer is driver-agnostic, while the schema builder is primarily tuned for MySQL-like syntax and SQLite.
2. Query Builder
SELECT
SELECT with aliases
INSERT
UPDATE
DELETE
Debug SQL
Raw expressions
Join support
Group By / Having
Aggregates
Exists
Value / Pluck
Value / Pluck with aliases
Pagination
Empty whereIn / whereNotIn
Available behaviors:
EMPTY_CONDITION_NONE(default forwhereIn) -> executes0 = 1EMPTY_CONDITION_ALL(default forwhereNotIn) -> executes1 = 1EMPTY_CONDITION_EXCEPTION-> throwsInvalidArgumentException
You can override whereNotIn separately:
3. Transactions
4. Global Helpers (with codemonster-ru/support)
If you also install codemonster-ru/support
and register bindings in your container, you can use global helpers:
Helpers are thin wrappers around DatabaseManager and the connection’s schema() / transaction() methods.
Schema Builder
The package includes a lightweight schema builder.
Note: The schema grammar is focused on MySQL/MariaDB and SQLite.
For other PDO drivers, the query builder will work, but schema operations may not be fully supported.
Creating a table
Modifying a table
SQLite notes
- SQLite supports
ALTER TABLEonly for a subset of operations; some drop operations are ignored. - Foreign keys are emitted inline during
CREATE TABLE.
Dropping a table
Supported Column Types
- Integers:
id,integer,bigInteger,mediumInteger,smallInteger,tinyInteger - Floats:
decimal,double,float - Text:
string,char,text,mediumText,longText - Boolean:
boolean - JSON:
json - Dates & time:
date,datetime,timestamp,time,year - UUID:
uuid - Indexes:
index,unique,primary - Foreign keys with
foreign()/references()/on()andonDelete()/onUpdate()helpers
Migrations
The package includes a migration system (designed to be used via the CLI).
migratemigrate:rollbackmigrate:statusmake:migrationseedmake:seed
Example migration
Seeders
The package includes a lightweight seeding system (via the CLI).
Example seeder
ORM (ActiveRecord / Eloquent‑style)
Since 1.3.0, the package includes a complete ORM layer:
ModelModelQueryModelCollection- Lazy & eager loading
$fillable,$guarded,$hidden- Attribute casting (
int,json,datetime, etc.) created_at/updated_atSoftDeletes
Example model
Fetching models
Creating / updating / deleting
Relationships
Available relations:
HasOneHasManyBelongsToBelongsToMany
Example
Lazy loading
Eager loading
Soft Deletes
$user->delete()→ setsdeleted_at$user->restore()User::onlyTrashed()User::withTrashed()
CLI Tool
A standalone CLI ships with the package:
Running migrations
Rollback
Status
Wipe database
Force wipe without confirmation:
Clean database data (keep migrations table)
Force clean without confirmation:
Create a migration
Migration names must be CamelCase using only Latin letters (e.g., CreateUsersTable). Names that include other symbols or casing styles are rejected.
Default migrations directory:
You can override paths via the migration kernel/path resolver:
Running seeders
Create a seeder
Seed names must be CamelCase using only Latin letters (e.g., UsersSeeder). Names that include other symbols or casing styles are rejected.
Default seeds directory:
You can override paths via the seed kernel/path resolver:
Tests
Author
License
All versions of database with dependencies
ext-pdo Version *