kevinsillo / phpjsondb
PhpJsonDB is a PHP library for managing databases using JSON files. It provides a simple, file-system based approach to database management with type-safe operations.
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/kevinsillo/phpjsondb
Requires
- php: >=8.2
Requires (Dev)
- phpunit/phpunit: ^11
This package is auto-updated.
Last update: 2025-12-25 01:03:35 UTC
README
π Overview
PhpJsonDB is a modern PHP library for managing databases using JSON files. It provides a simple, file-system based approach to database management with type-safe operations. Perfect for small to medium projects! π
π Key Features
- π‘ Lightweight JSON-based database management
- π File-system based table storage
- π Type-safe CRUD operations
- π Advanced querying capabilities
- π€ Export and import functionality
π οΈ Installation
# Instala fΓ‘cilmente con Composer π
composer require kevinsillo/phpjsondb
π§° Methods Overview
| π§ Method | π Description |
|---|---|
getTables() |
Gets a list of all tables. |
getTablesInfo() |
Gets detailed information of all tables. |
tableRecords() |
Return the number of all records in the table. |
tableExists() |
Checks if a table (directory) exists. |
selectTable() |
Selects a table (directory) to work with. |
createTable() |
Creates a new table (directory). |
truncate() |
Truncates the table, removing all records but keeping the table and its control file. |
dropTable() |
Deletes a table (directory) and all its records. |
select() |
Selects specific fields to be returned in the query result. |
where() |
Applies search criteria with type-safe operators. |
findById() |
Finds a record by its ID. |
insertAuto() |
Inserts a new record using an auto-incremental ID. |
insert() |
Inserts a new record. |
update() |
Updates records selected. |
updateById() |
Updates an existing record. |
delete() |
Deletes records selected. |
deleteById() |
Deletes a record. |
limit() |
Applies pagination to the query. |
orderBy() |
Applies ordering to the result set. |
getRecords() |
Gets the records in the current result set. |
countRecords() |
Gets the count of records in the current result set. |
existsById() |
Checks if a record with the given ID exists. |
hasRecords() |
Checks if any records exist in the current result set. |
exportDatabase() |
Exports the entire database to a JSON file. |
importDatabase() |
Imports a database from a JSON file. |
π‘ Quick Example
$db = new PhpJsonDB(); $db->table('users')->insert([ 'name' => 'John Doe', 'email' => 'john@example.com' ]);
π€ Contributing
Contributions are welcome! π Submit pull requests or open issues.
π License
MIT License