PHPackages                             xonite/light-db-layer - 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. xonite/light-db-layer

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

xonite/light-db-layer
=====================

Lightweight php database abstraction layer to work closer to real data.

v1.0(2y ago)150MITPHPPHP &gt;=8.3

Since Feb 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/xonite/light-db-layer)[ Packagist](https://packagist.org/packages/xonite/light-db-layer)[ RSS](/packages/xonite-light-db-layer/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

light-db-layer
==============

[](#light-db-layer)

Lightweight php database abstraction layer to work closer to real data.

Idea of this library is to work as close to your data as you can. Most performance issues are created by not understanding data that lies in database server. This is definitely not an ORM, and creates almost no overhead. You can think of this library as convention wrapper to help organize your code, with helper methods for simple operations.

> Give power back to your database and learn more about your data to write better code.

Installation
============

[](#installation)

Symfony 5+
----------

[](#symfony-5)

Add this configuration to config/services.yaml

```
Doctrine\DBAL\Configuration:

Doctrine\DBAL\Connection:
    factory: 'Doctrine\DBAL\DriverManager::getConnection'
    arguments:
        - url: '%env(DATABASE_URL)%'
          driverOptions: {20: false} # emulate prepared statements
        - '@Doctrine\DBAL\Configuration'

```

In your env files add

```
DATABASE_URL=mysql://user:password@server:port/table?serverVersion=8.0&charset=utf8

```

Usage
=====

[](#usage)

Entity example
--------------

[](#entity-example)

```
namespace App\Entity;

use App\Entity;
use Brick\Money\Money;

class FacilityMeal extends Entity
{
    public int $facilityId;
    public int $mealTypeId;
    public Money $expectedCost;
    public \DateTime $date;

    public function expectedCostFormatter(): string
    {
        return (string)$this->expectedCost->getAmount();
    }

    public function dateFormatter(): string
    {
        return $this->date->format('Y-m-d');
    }
}

```

Entities are used only for insertions or updates. You can define whatever types you want, make it pure php 7.4 style or use getters/setters. Formatters will run to transform your data to database manageable format. You should not define variables that should be managed by your database, for example id or at least make those private just like on creation timestamp. Entity class and repositories will make naming convention transfer to use CamelCase in php and lowercase underscore in database.

Entity have methods for self:

- insert
- update
- delete
- findId

Repository Example
------------------

[](#repository-example)

```
class Facility extends Repository
{
    public function getUserFacilities(int $userId): Statement
    {
        return $this->db->executeQuery('SELECT `facility`.*
                FROM `facility`
                INNER JOIN `user_role` ON `facility`.`id`=`user_role`.`facility_id`
                WHERE `user_role`.`user_id`=?',
            [$userId]
        );
    }

}

```

Repository is just place for your queries. It's based on doctrine/dbal for future extendability but it's really nothing more than simple PDO. Repository contains helper methods for:

- reducer to basic array
- reducer to id array
- field value migration
- unique migration
- array to query parameter helper

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity70

Established project with proven stability

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

Total

3

Last Release

773d ago

Major Versions

v0.2.1 → v1.02024-05-21

PHP version history (2 changes)v0.2PHP &gt;=8.0

v1.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e52cb2c6fc5f0944149a379ca96c346d6a8f6c5deac03365a88a0f909506433?d=identicon)[Xitro](/maintainers/Xitro)

---

Top Contributors

[![Xitro](https://avatars.githubusercontent.com/u/3830615?v=4)](https://github.com/Xitro "Xitro (9 commits)")

---

Tags

mysqldbaldb

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xonite-light-db-layer/health.svg)

```
[![Health](https://phpackages.com/badges/xonite-light-db-layer/health.svg)](https://phpackages.com/packages/xonite-light-db-layer)
```

###  Alternatives

[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4585.8M4](/packages/martin-georgiev-postgresql-for-doctrine)[envms/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

925539.6k13](/packages/envms-fluentpdo)[lichtner/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

930286.0k6](/packages/lichtner-fluentpdo)[fpdo/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

922251.8k8](/packages/fpdo-fluentpdo)[flow-php/doctrine-dbal-bulk

Bulk inserts and updates for Doctrine DBAL

14385.8k4](/packages/flow-php-doctrine-dbal-bulk)[nettrine/dbal

Doctrine DBAL for Nette Framework

332.7M24](/packages/nettrine-dbal)

PHPackages © 2026

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