PHPackages                             yepsql/yepsql - 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. yepsql/yepsql

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

yepsql/yepsql
=============

SQL templating helper for PHP inspired by yesql.

v0.2.0(8y ago)15481[1 issues](https://github.com/LionsHead/YepSQL/issues)MITPHPPHP &gt;=5.4.0

Since Feb 7Pushed 6y ago1 watchersCompare

[ Source](https://github.com/LionsHead/YepSQL)[ Packagist](https://packagist.org/packages/yepsql/yepsql)[ Docs](https://github.com/LionHeads/YepSQL)[ RSS](/packages/yepsql-yepsql/feed)WikiDiscussions master Synced 4w ago

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

YepSQL [![Build Status](https://camo.githubusercontent.com/7cc6c52a2e968a0d3e521c90aedcf057a3ea0a37309867fe5ff55817d407b5a3/68747470733a2f2f7472617669732d63692e6f72672f4c696f6e73486561642f59657053514c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/LionsHead/YepSQL)
======================================================================================================================================================================================================================================================================================

[](#yepsql-)

SQL templating helper for PHP inspired by [yesql](https://github.com/krisajenkins/yesql).

Requirements: php &gt;= 5.6; pdo\_extension;

Install: composer require yepsql/yepsql

Usage
-----

[](#usage)

Create a file containing your SQL queries

### File example:

[](#file-example)

```
-- name: sqlQueryName
-- query annotation
SELECT count(*) FROM `table`;

-- name: getUsersInfo
-- request annotation 1 ...
-- request annotation 2 ...
SELECT *
FROM `table`
WHERE `user_id` = ? ;

-- name: updateUserName
UPDATE `table`
SET `user_name` = :user_name
WHERE `user_id` = :user_id ;
```

And call them in your code. Notice: "query-name" is converted to "query\_name", php does not support this name methods.

### Example:

[](#example)

```
  $sql_template = new \YepSQL\Builder(
    new PDO_instance('sqlite::memory:'),    // you instance of PDO
    '/path/to/file.sql'                     // file with queries
  );

  // prepare SELECT * FROM `table` WHERE `user_id` = ? ;
  // and send query "getUsersInfo":
  // SELECT * FROM `table`  WHERE `user_id` = 128;
  $user_id = 128; // request arguments
  $stmt = $sql_template->getUsersInfo($user_id);
  // returned PDOStatement instance
  $user_data = $stmt->fetch(PDO::FETCH_ASSOC);

  // send query "updateUserName":
  // UPDATE `table` SET `user_name` = 'NewUSerName' WHERE `user_id` = '128';
  $sql_template->updateUserName([
     ':user_name' => 'NewUSerName',
     ':user_id' => 128
  ]);
```

Enjoy.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.4% 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 ~582 days

Total

2

Last Release

3213d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2943862?v=4)[Александр](/maintainers/LionsHead)[@LionsHead](https://github.com/LionsHead)

---

Top Contributors

[![LionsHead](https://avatars.githubusercontent.com/u/2943862?v=4)](https://github.com/LionsHead "LionsHead (37 commits)")[![runejuhl](https://avatars.githubusercontent.com/u/626791?v=4)](https://github.com/runejuhl "runejuhl (1 commits)")

---

Tags

phpyesqlmysqlsqlitepostgresqlsqlpdoyesql

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.5k](/packages/doctrine-dbal)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4563.1M37](/packages/aura-sqlquery)[ezsql/ezsql

Advance database access library. Make interacting with a database ridiculously easy. An universal interchangeable CRUD system.

86748.3k](/packages/ezsql-ezsql)[jv2222/ezsql

Advance database access library. Make interacting with a database ridiculously easy. An universal interchangeable CRUD system.

86811.4k2](/packages/jv2222-ezsql)[atlas/query

Object-oriented query builders and performers for MySQL, Postgres, SQLite, and SQLServer.

41253.7k7](/packages/atlas-query)[aura/sqlschema

Provides facilities to read table names and table columns from a database using PDO.

41240.2k4](/packages/aura-sqlschema)

PHPackages © 2026

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