PHPackages                             crodas/easy-sql - 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. crodas/easy-sql

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

crodas/easy-sql
===============

Easiest SQL abstraction ever

743PHP

Since Feb 29Pushed 10y ago1 watchersCompare

[ Source](https://github.com/crodas/EasySQL)[ Packagist](https://packagist.org/packages/crodas/easy-sql)[ RSS](/packages/crodas-easy-sql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

EasySQL
=======

[](#easysql)

Easiest SQL abstraction ever, heavily inspired by [yesql](https://github.com/krisajenkins/yesql)

Concepts
--------

[](#concepts)

I've been in a quest all my professional life, create the simplest SQL-abstraction for PHP. I [gave up](https://github.com/crodas/ActiveMongo2) many times until I saw [yesql](https://github.com/krisajenkins/yesql)'s simplicity.

It's a tiresome task to reinvent SQL, and often in vain. You need to give away functionality (what makes SQL unique) or performance (something unthinkable for most web apps).

How does it work?
-----------------

[](#how-does-it-work)

EasySQL is heavily inspired by [yesql](https://github.com/krisajenkins/yesql), that means you have a different file with a list of SQL statements, which is compiled to a PHP class with all those operations.

```
-- This file is saved as queries/users.sql
-- @name byEmail
SELECT * FROM user WHERE email = $email LIMIT 1;

-- @name getContacts
SELECT
  u.id, u.name, u.email
FROM user
INNER JOIN contacts c (c.friend_of = u.id)
WHERE c.user_id = $me;

-- @name create
INSERT INTO user(email) VALUES($email);
```

Then you need the following PHP bootstrap code to get it running:

```
$repo = new EasySQL\EasySQL("queries", $pdo);
$users = $repo->getRepository("users");

// find and return a single row due to the `LIMIT 1`. To force
// a single row we can use @One annotation.
$me = $users->byEmail("crodas@php.net");

// All `INSERT` return the new created ID
$user_id = $users->create("crodas@php.net");
```

Underneath the EasySQL's compiler will read all files and their SQL statements and generate a PHP file with all the queries and bootstrap code.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/36463?v=4)[C](/maintainers/crodas)[@crodas](https://github.com/crodas)

---

Top Contributors

[![crodas](https://avatars.githubusercontent.com/u/36463?v=4)](https://github.com/crodas "crodas (44 commits)")

### Embed Badge

![Health badge](/badges/crodas-easy-sql/health.svg)

```
[![Health](https://phpackages.com/badges/crodas-easy-sql/health.svg)](https://phpackages.com/packages/crodas-easy-sql)
```

###  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)
