PHPackages                             stormmore/queries - 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. stormmore/queries

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

stormmore/queries
=================

1.0.6(1y ago)032PHPCI passing

Since Feb 6Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/stormmoredev/storm-php-queries)[ Packagist](https://packagist.org/packages/stormmore/queries)[ RSS](/packages/stormmore-queries/feed)WikiDiscussions main Synced today

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

StormPHP Queries
================

[](#stormphp-queries)

A lightweight **query builder** and **ORM** for PHP. ⚡ Fast, intuitive, and flexible — without heavy configuration or boilerplate.

- 🚀 **Hierarchical models** — benefit from ORM features without over-configuration
- 🔎 **Fluent query builder** with modern criteria-finder pattern
- 📦 **Zero configuration** — no need to describe DB schema
- 🗄️ Works with multiple databases (PostgreSQL, MySQL, MariaDB, MSSQL, SQLite)
- 🧹 **Lightweight** — tidy code, no extra dependencies
- 🛠️ Developer-friendly — SQL profiling &amp; logging

---

Why StormPHP Queries?
---------------------

[](#why-stormphp-queries)

Most ORMs are either too heavy or too limited. StormPHP Queries strikes the balance:

- ✅ **No configuration required** — just connect and start querying
- ✅ **Clean domain models** — keep your DDD aggregates free from persistence concerns
- ✅ **Fluent and flexible API** — build simple or complex queries step by step
- ✅ **Lightweight and dependency-free** — fast to learn, easy to maintain

If you need the power of an ORM combined with the clarity of a query builder — StormPHP Queries is for you.

---

Quick Start
-----------

[](#quick-start)

### Installation

[](#installation)

```
composer require stormmore/queries
```

### Establishing a Connection

[](#establishing-a-connection)

StormPHP Queries uses PDO:

```
use Stormmore\Queries\ConnectionFactory;
use Stormmore\Queries\StormQueries;

$connection = ConnectionFactory::createFromString("dsn", "user", "password");
$queries = new StormQueries($connection);
```

### Minimal Example

[](#minimal-example)

```
// Select
$product = $queries->find('products', ['id' => 5]);

// Insert
$id = $queries->insert('products', [
    'name' => 'Golden watch',
    'price' => 465
]);

// Update
$queries->update('products', ['id' => $id], ['name' => 'Renamed product']);

// Delete
$queries->delete('products', ['id' => $id]);
```

---

Basic Queries
-------------

[](#basic-queries)

Find product by ID:

```
$product = $queries->find('products', ['id' => 5]);
```

Find all products in a category:

```
$products = $queries->findAll('products', ['category_id' => 10]);
```

Count products:

```
$count = $queries->count('products', ['in_sale' => true]);
```

Check existence:

```
$exists = $queries->exist('products', ['id' => 5]);
```

Map records to a custom class:

```
use Stormmore\Queries\Mapper\Map;

$product = $queries->find('products', ['id' => 5], Map::select([
    'product_id'   => 'id',
    'product_name' => 'name'
], UserProduct::class));
```

---

ORM
---

[](#orm)

StormPHP Queries supports mapping query results to classes. Example:

```
$customers = $queries
    ->select('customers c', Map::select([
        'customer_id'   => 'id',
        'customer_name' => 'name'
    ]))
    ->leftJoin('orders o', 'o.customer_id = c.customer_id', Map::many("orders", [
        'order_id' => 'id'
    ]))
    ->findAll();
```

For the ORM to work without additional configuration:

- each record must have a unique identifier (by default id, but this can be changed using the classId parameter),
- tables in the query must have aliases.

This allows StormQueries to map records to user-defined objects, even if the key fields differ from the standard id.

```
$customer = $this->queries
    ->select('customers c', Map::select([
        'customer_id',
        'customer_name'
    ], Customer::class, classId: 'customer_id'))
    ->leftJoin('orders o', 'o.customer_id = c.customer_id', Map::many("orders", [
        'order_id'
    ], Order::class, classId: 'order_id'))
    ->where('c.customer_id', 90)
    ->find();

foreach ($customer->orders as $order) {
    echo $customer->customer_name . " - " . $order->id;
}
```

---

Guide
-----

[](#guide)

Looking for more? The full guide includes detailed sections on **Select Queries, ORM, Subqueries, Insert/Update/Delete, Union, Profiling, and more.**

👉 Read here: [Full Documentation – docs/guide.md](https://boltwebengine.github.io/storm-php-queries/)

---

Profiling
---------

[](#profiling)

You can log queries using callbacks:

```
$connection->onSuccess(function(string $sql, DateInterval $interval) {
    // log successful queries
});

$connection->onFailure(function(string $sql, DateInterval $interval, Exception $e) {
    // log failed queries
});
```

---

Notice
------

[](#notice)

- StormPHP Queries uses **PDO**.
- Tested with **PostgreSQL, MySQL, MariaDB, SQL Server, SQLite**.
- Requires **PHP 8.0+**.

---

Tests
-----

[](#tests)

Run tests using Docker:

```
docker-compose up
./run.mysql.cmd
```

---

Examples
--------

[](#examples)

Check the `tests` directory for more detailed examples.

---

Contributing
------------

[](#contributing)

Contributions are welcome!

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/your-feature`)
3. Commit your changes (`git commit -m "Add new feature"`)
4. Push to your branch (`git push origin feature/your-feature`)
5. Open a Pull Request

---

Author
------

[](#author)

**Michał Czerski**If you have questions or ideas, feel free to reach out on GitHub.

---

License
-------

[](#license)

StormPHP Queries is licensed under the **MIT License**.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance57

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Recently: every ~54 days

Total

10

Last Release

281d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23155715?v=4)[Stormmore](/maintainers/Stormmore)[@stormmore](https://github.com/stormmore)

---

Top Contributors

[![michalczerski](https://avatars.githubusercontent.com/u/13020847?v=4)](https://github.com/michalczerski "michalczerski (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198741.5k12](/packages/pgvector-pgvector)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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