PHPackages                             micoli/elql - 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. micoli/elql

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

micoli/elql
===========

v0.7.0(1y ago)3109MITPHPPHP &gt;=8.1

Since Jul 14Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (15)Versions (8)Used By (0)

Micoli\\Elql
============

[](#micolielql)

A flat database manager. Each models are read/persisted in a (`YAML`|`JSON`) file.

That library is based upon [`symfony/serializer`](https://symfony.com/doc/current/components/serializer.html) and [`symfony/expression-language`](https://symfony.com/doc/current/components/expression_language.html) components. So basically, every model that can be serialized/deserialized by those components wan be used.

When `select`ing, `updat`ing, `delet`ing records, each constraints are expressed as an `expression-language` string. A `record` object is available in the constraint expression and represent the evaluated record.

[![Build Status](https://github.com/micoli/elql/workflows/Tests/badge.svg)](https://github.com/micoli/elql/actions)[![Coverage Status](https://camo.githubusercontent.com/2ba264e7cd1c781cbbbf0f452a3065cf258de3bc85adca14282d7630aa4a4d3d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d69636f6c692f456c716c2f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/micoli/Elql?branch=main)[![Latest Stable Version](https://camo.githubusercontent.com/e566579eec34e4b1d38c54916f0b1d74ef212a176648c361f4df3d160f4de9f1/687474703a2f2f706f7365722e707567782e6f72672f6d69636f6c692f656c716c2f76)](https://packagist.org/packages/micoli/elql)[![Total Downloads](https://camo.githubusercontent.com/b9a81b13e3831fce8f5f263df1ff5232fdbe9c6bfedd73f52bc3da0d6ff9a96a/687474703a2f2f706f7365722e707567782e6f72672f6d69636f6c692f656c716c2f646f776e6c6f616473)](https://packagist.org/packages/micoli/elql)[![Latest Unstable Version](https://camo.githubusercontent.com/cbe19c599de1bfff53da4ddf729624513121bfb02b33abcda129283caa9b859e/687474703a2f2f706f7365722e707567782e6f72672f6d69636f6c692f656c716c2f762f756e737461626c65)](https://packagist.org/packages/micoli/elql) [![License](https://camo.githubusercontent.com/c5f4cb2cfaa6fb8855996ccde6de89dd6cb3c93a53d3103a391aa71090a94fd1/687474703a2f2f706f7365722e707567782e6f72672f6d69636f6c692f656c716c2f6c6963656e7365)](https://packagist.org/packages/micoli/elql)[![PHP Version Require](https://camo.githubusercontent.com/805a0cf0d5f91b59ed9291486c698003c5600a3a63754af85f816902fdec503e/687474703a2f2f706f7365722e707567782e6f72672f6d69636f6c692f656c716c2f726571756972652f706870)](https://packagist.org/packages/micoli/elql)

Installation
------------

[](#installation)

This library is installable via [Composer](https://getcomposer.org/):

```
composer require micoli/elql
```

Requirements
------------

[](#requirements)

This library requires PHP 8.0 or later.

Project status
--------------

[](#project-status)

While this library is still under development, it is still in early development status. It follows semver version tagging.

Quick start
-----------

[](#quick-start)

### Create an instance of Elql manager

[](#create-an-instance-of-elql-manager)

Database are per directory. all models are persisted in a separate file.

```
$database = new Elql(
    new FilePersister(
        '/var/lib/database',
        new MetadataManager(),
        YamlEncoder::FORMAT,
    ),
);
```

The persisted records are loaded in memory before each CRUD action if they were not already loaded.

### Record in memory addition

[](#record-in-memory-addition)

Add some record of proper serializable model.

```
$database->add(
    new Baz(1, 'a', 'a'),
    new Baz(2, 'b', 'b'),
    new Baz(3, 'c', 'c'),
    new Baz(4, 'd', 'd'),
    new Foo(1, 'aa', new DateTimeImmutable()),
);
```

### Basic crud function are available

[](#basic-crud-function-are-available)

#### Select

[](#select)

```
$records = $database->find(Baz::class, 'record.id==3');
```

#### Update

[](#update)

An updater callback is used to help case/case model updates

```
$database->update(Baz::class, function (Baz $record) {
    $record->firstName = $record->firstName . '-updated';

    return $record;
}, 'record.id==3');
```

#### Delete

[](#delete)

```
$database->delete(Baz::class, 'record.id in [1,4]');
```

#### Count

[](#count)

```
print $database->count(Baz::class, 'record.id in [1,4]');
```

#### You need to flush the in-memories tables to disk to persist them

[](#you-need-to-flush-the-in-memories-tables-to-disk-to-persist-them)

```
$database->persister->flush();
```

```
/var/lib/database/Foo.yaml
/var/lib/database/Bar.yaml

```

Attributes
----------

[](#attributes)

### Table($name)

[](#tablename)

Instead of using the class-name as filename, you can specify a specific name using that attribute.

```
#[Table('b_a_z')]
class Baz
{
    public function __construct(
        public readonly int $id,
        public string $firstName,
        public string $lastName,
    ) {
    }
}
```

N.B.:

if you don't want to use that attribute, you can specify some filenames in the `MetadataManager` constructor.

```
$database = new Elql(
    new FilePersister(
        '/var/lib/database',
        new MetadataManager([
            Foo::class=>'foo_table'
        ]),
        YamlEncoder::FORMAT,
    ),
);
```

In that was, when `Foo` records will be persisted, the filename will be `foo_table.yaml`.

### Unique($expression, $indexName)

[](#uniqueexpression-indexname)

Before adding a record to a model table, the unique constraints are evaluated to guarantee uniqueness of records.

```
#[Unique('record.id')]
#[Unique('[record.firstName,record.lastName]', 'fullname')]
class Baz
{
    public function __construct(
        public readonly int $id,
        public string $firstName,
        public string $lastName,
    ) {
    }
}
```

A `Micoli\Elql\Exception\NonUniqueException` are triggered in case of a constraint is not respected.

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance41

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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 ~90 days

Recently: every ~135 days

Total

7

Last Release

491d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

databasejsonphp-libraryphp8symfonyyaml

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/micoli-elql/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)

PHPackages © 2026

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