PHPackages                             theopenweb/lessql - 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. theopenweb/lessql

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

theopenweb/lessql
=================

LessQL: A lightweight and performant PHP ORM alternative

00PHP

Since Jul 14Pushed 1y agoCompare

[ Source](https://github.com/theopenwebjp/lessql)[ Packagist](https://packagist.org/packages/theopenweb/lessql)[ RSS](/packages/theopenweb-lessql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

LessQL
======

[](#lessql)

LessQL is a lightweight and performant alternative to Object-Relational Mapping for PHP.

**[Guide](doc/guide.md) | [Conventions](doc/conventions.md) | [API Reference](doc/api.md) | [About](doc/about.md)**

*If you are looking for an SQL-based approach superior to raw PDO, check out [DOP](https://github.com/morris/dop) as an alternative.*

Fork Notes
----------

[](#fork-notes)

- The notes in this section outlines information regarding differences with the original repository: [morris/lessql](https://github.com/morris/lessql)
- Other sections MAY have ONLY important/appropriate updates made to them compared with the original repository.
- Reasons for fork:
    - Last update is old:
        - (May 10, 2020 at time of writing): [Releases](https://github.com/morris/lessql/releases)
        - [Is this project still maintained?](https://github.com/morris/lessql/issues/39)
        - [Next release...](https://github.com/morris/lessql/issues/29)
    - Errors/warnings when using with newer PHP versions:
        - PHP 8.1 deprecated errors such as with "offsetExists".
        - Row not found exception. require\_once of Row fixed it.
    - Still using it in some projects so need to have a working up-to-date source(installed via composer through packagist.).
- Notes:
    - [morris/dop](https://github.com/morris/dop) is mentioned as an alternative, but it does not seem to have much development or be maintained.

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

[](#installation)

Install LessQL via composer: `composer require theopenweb/lessql`. LessQL requires PHP &gt;= 8.0 and PDO.

Usage
-----

[](#usage)

```
// SCHEMA
// user: id, name
// post: id, title, body, date_published, is_published, user_id
// categorization: category_id, post_id
// category: id, title

// Connection
$pdo = new PDO('sqlite:blog.sqlite3');
$db = new LessQL\Database($pdo);

// Find posts, their authors and categories efficiently:
// Eager loading of references happens automatically.
// This example only needs FOUR queries, one for each table.
$posts = $db->post()
    ->where('is_published', 1)
    ->orderBy('date_published', 'DESC');

foreach ($posts as $post) {
    $author = $post->user()->fetch();

    foreach ($post->categorizationList()->category() as $category) {
        // ...
    }
}

// Saving complex structures is easy
$row = $db->createRow('post', [
    'title' => 'News',
    'body' => 'Yay!',
    'categorizationList' => [
        [
            'category' => ['title' => 'New Category']
        ],
        ['category' => $existingCategoryRow]
    ]
]);

// Creates a post, a new category, two new categorizations
// and connects them all correctly.
$row->save();
```

Features
--------

[](#features)

- Efficient deep finding through intelligent eager loading
- Constant number of queries, no N+1 problems
- Save complex, nested structures with one method call
- Convention over configuration
- Work closely to your database: LessQL is not an ORM
- No glue code required
- Clean, readable source code
- Fully tested with SQLite3, MySQL and PostgreSQL
- MIT license

Inspired mainly by [NotORM](https://www.notorm.com/), it was written from scratch to provide a clean API and simplified concepts.

Contributors
------------

[](#contributors)

- [theopenwebjp](https://github.com/theopenwebjp)
- [jayaddison](https://github.com/jayaddison)
- [f0ma](https://github.com/f0ma)

Thanks!

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity20

Early-stage or recently created project

 Bus Factor1

Top contributor holds 86.2% 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.

### Community

Maintainers

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

---

Top Contributors

[![morris](https://avatars.githubusercontent.com/u/32837?v=4)](https://github.com/morris "morris (106 commits)")[![CQD](https://avatars.githubusercontent.com/u/94944?v=4)](https://github.com/CQD "CQD (5 commits)")[![palicao](https://avatars.githubusercontent.com/u/659961?v=4)](https://github.com/palicao "palicao (3 commits)")[![goldingdamien](https://avatars.githubusercontent.com/u/4121813?v=4)](https://github.com/goldingdamien "goldingdamien (2 commits)")[![metala](https://avatars.githubusercontent.com/u/120106?v=4)](https://github.com/metala "metala (1 commits)")[![nataliawinter](https://avatars.githubusercontent.com/u/9592064?v=4)](https://github.com/nataliawinter "nataliawinter (1 commits)")[![cos800](https://avatars.githubusercontent.com/u/635184?v=4)](https://github.com/cos800 "cos800 (1 commits)")[![vikkio88](https://avatars.githubusercontent.com/u/248805?v=4)](https://github.com/vikkio88 "vikkio88 (1 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")[![jayaddison](https://avatars.githubusercontent.com/u/55152140?v=4)](https://github.com/jayaddison "jayaddison (1 commits)")[![luiz-brandao](https://avatars.githubusercontent.com/u/704231?v=4)](https://github.com/luiz-brandao "luiz-brandao (1 commits)")

### Embed Badge

![Health badge](/badges/theopenweb-lessql/health.svg)

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

###  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)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

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

Reliese Components for Laravel Framework code generation.

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

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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