PHPackages                             zidbih/filequent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. zidbih/filequent

ActiveLibrary[Database &amp; ORM](/categories/database)

zidbih/filequent
================

A lightweight file-based ORM for PHP using JSON files, inspired by Eloquent.

v0.2.0(10mo ago)010MITPHPPHP &gt;=8.1

Since Jun 21Pushed 6mo agoCompare

[ Source](https://github.com/medmahmoudhdaya/filequent)[ Packagist](https://packagist.org/packages/zidbih/filequent)[ RSS](/packages/zidbih-filequent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

📂 Filequent
===========

[](#-filequent)

**A lightweight, file-based ORM-like system for PHP**
Developed by **Zidbih**

---

**Filequent** allows you to build and interact with data models in a clean, Eloquent-style syntax — without using a traditional database. Data is saved to structured JSON files, making this ideal for local development, prototypes, lightweight apps, or embedded systems.

---

🚀 Features
----------

[](#-features)

- Eloquent-style model structure
- Stores data as JSON files (no database required)
- Simple CRUD support: `create`, `find`, `all`, `update`, `delete`, `where`, etc.
- Relationship support: `hasMany`, `hasOne`, `belongsTo`
- Default and custom foreign key handling
- Extensible and easy to test
- Fully tested with PHPUnit

---

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require zidbih/filequent
```

---

🧱 Defining Models
-----------------

[](#-defining-models)

Create model classes by extending `Zidbih\Filequent\Filequent` and define:

- `$collection` — JSON file name (without `.json`)
- `$basePath` (optional) — directory where the file is saved

```
use Zidbih\Filequent\Filequent;

class User extends Filequent
{
    protected static string $collection = 'users';
    protected static ?string $basePath = __DIR__ . '/data';

    public function posts()
    {
        return $this->hasMany(Post::class);
    }

    public function latestPost()
    {
        return $this->hasOne(Post::class);
    }
}

class Post extends Filequent
{
    protected static string $collection = 'posts';
    protected static ?string $basePath = __DIR__ . '/data';

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}
```

---

✨ CRUD Operations
-----------------

[](#-crud-operations)

### Create

[](#create)

```
$user = User::create(['name' => 'Alice']);
```

### Read

[](#read)

```
$found = User::find($user->id);// by ID
$allUsers = User::all();// all records
```

### Update

[](#update)

```
$user->update(['name' => 'Updated']);
```

### Delete

[](#delete)

```
$user->delete();
```

---

🔍 Query Builder
---------------

[](#-query-builder)

Filequent supports method chaining similar to Eloquent:

```
$results = User::where('name', '=', 'Alice')->get();

$firstMatch = User::where('age', '>', 25)->first();

$likeMatches = User::where('name', 'LIKE', 'Ah%')->get();
```

Supported operators: `=`, `!=`, `>`, `posts(); // Returns all posts with user_id = $user->id
```

### hasOne

[](#hasone)

```
$post = $user->latestPost(); // Returns one related Post
```

### belongsTo

[](#belongsto)

```
$post = Post::find(1);
$user = $post->user(); // Returns the User who owns the post
```

### Custom Foreign Key

[](#custom-foreign-key)

You can specify a custom foreign key:

```
return $this->belongsTo(User::class, 'custom_user_id');
```

---

💾 Where Is Data Stored?
-----------------------

[](#-where-is-data-stored)

By default, JSON files are saved in a `/data` folder under the project root.

```
your-project/
├── data/
│   ├── users.json
│   └── posts.json
```

You can override this using the static `$basePath` property on each model.

---

🧪 Testing
---------

[](#-testing)

Filequent includes a fully-featured test suite using **PHPUnit**.

### Setup

[](#setup)

```
vendor/bin/phpunit
```

### Structure

[](#structure)

```
tests/
├── FilequentTest.php
├── testData/
│   ├── users.json
│   └── posts.json

```

The tests cover:

- File-level operations (insert/read)
- All CRUD methods
- Advanced query logic (chaining, LIKE)
- Relationship resolution
- Custom foreign keys
- Error cases and edge handling

---

📂 Example Usage
---------------

[](#-example-usage)

```
$user = User::create(['name' => 'Ahmed']);

Post::create([
    'title' => 'Hello World',
    'body' => 'Welcome to Filequent!',
    'user_id' => $user->id,
]);

// Retrieve all posts by this user
$posts = $user->posts();

// Get the user for a post
$post = Post::find(1);
$owner = $post->user();
```

---

🧑‍💻 Author
----------

[](#‍-author)

**Zidbih**
GitHub:

---

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

---

🤝 Contributing
--------------

[](#-contributing)

Pull requests, bug reports, and suggestions are welcome!

If you like the package, consider ⭐ starring it on GitHub and sharing it with others.

---

*Filequent — Simplify data storage, without a database.*

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance60

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

324d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b8435c1650e36d1af5d86c9955e343d4ce94ad62949a09e43c4f5cc1a47dba79?d=identicon)[medmahmoudhdaya](/maintainers/medmahmoudhdaya)

---

Top Contributors

[![medmahmoudhdaya](https://avatars.githubusercontent.com/u/192469611?v=4)](https://github.com/medmahmoudhdaya "medmahmoudhdaya (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zidbih-filequent/health.svg)

```
[![Health](https://phpackages.com/badges/zidbih-filequent/health.svg)](https://phpackages.com/packages/zidbih-filequent)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
