PHPackages                             m.rahimi/astro-orm - 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. m.rahimi/astro-orm

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

m.rahimi/astro-orm
==================

Simple Object Relational Mapper for manipulate data with fluent interface.

v2.1.0(2y ago)351[2 issues](https://github.com/Mohammadreza-73/Astro-ORM/issues)MITPHPPHP ^7.2.5||^8.0

Since Nov 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Mohammadreza-73/Astro-ORM)[ Packagist](https://packagist.org/packages/m.rahimi/astro-orm)[ Docs](https://github.com/Mohammadreza-73/Astro-ORM)[ Fund](https://daramet.com/mrahimi)[ RSS](/packages/mrahimi-astro-orm/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (3)Versions (11)Used By (0)

[![astro-orm-banner](https://camo.githubusercontent.com/a92f0316d5d97da8c1a58b945af5219e89096a905e4ec22837536429d1c6fa32/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f417374726f2532304f524d2e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6d2e726168696d69253246617374726f2d6f726d267061747465726e3d62616d626f6f267374796c653d7374796c655f31266465736372697074696f6e3d6c696768747765696768742b5048502b4f524d266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d68747470732533412532462532467777772e7068702e6e6574253246696d616765732532466c6f676f732532466e65772d7068702d6c6f676f2e737667267769647468733d33353026686569676874733d333530)](https://camo.githubusercontent.com/a92f0316d5d97da8c1a58b945af5219e89096a905e4ec22837536429d1c6fa32/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f417374726f2532304f524d2e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6d2e726168696d69253246617374726f2d6f726d267061747465726e3d62616d626f6f267374796c653d7374796c655f31266465736372697074696f6e3d6c696768747765696768742b5048502b4f524d266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d68747470732533412532462532467777772e7068702e6e6574253246696d616765732532466c6f676f732532466e65772d7068702d6c6f676f2e737667267769647468733d33353026686569676874733d333530)

 [![Total Downloads](https://camo.githubusercontent.com/e83057ed645fc1556d986666901305f580a32f2a8c3c2166f31afb3ce16d6144/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d2e726168696d692f617374726f2d6f726d)](https://packagist.org/packages/m.rahimi/astro-orm) [![Latest Stable Version](https://camo.githubusercontent.com/5e8914e1d4e0b0feff0fc1cdf0263255af4c1d0779311efa19a75fac50eeadf1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d2e726168696d692f617374726f2d6f726d)](https://packagist.org/packages/m.rahimi/astro-orm) [![StyleCI](https://camo.githubusercontent.com/f75ac9f2c3fb794617336282215a933e1463be46eb8ab308ed22a3d68bc0db22/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3433333035383732342f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/433058724?branch=master) [![License](https://camo.githubusercontent.com/75237817c24965fee0b584355d792ffbc15785a61b3d9642a321e1dba4d5199d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d2e726168696d692f617374726f2d6f726d)](https://packagist.org/packages/m.rahimi/astro-orm) [![PHPStan](https://camo.githubusercontent.com/742e8be8005b1fe76a64a5d8f5e6a5d4f63bf315e9a44a6d23e4e11c76b0555f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230362d627269676874677265656e2e7376673f7374796c653d666c6174)](https://phpstan.org/)

object-relational mapper (ORM), lets you query and manipulate data with fluent api from a database using an object-oriented paradigm.

📌 Requirements
--------------

[](#-requirements)

- PHP &gt;= 7.2
- PDO Extension

⬇️ Installation
---------------

[](#️-installation)

You can install the package via the composer:

```
composer require m.rahimi/astro-orm

```

👀 How its works
---------------

[](#-how-its-works)

 [![UML](docs/UML Diagram.jpg)]()

### 1. Setup your database configs

[](#1-setup-your-database-configs)

Fill the `config/database.php` file with your database configuration.

**NOTE:** You Can use any database extensions, like: PDO, Mysqli, Sqlite,etc. Just define its array key.

### 2. Implements Connection Contract

[](#2-implements-connection-contract)

In this project i use PDO driver. so i create `Database/PDODatabaseConnection.php` file and implements contracts methods.

```
connect();        // Which implements database connection
getConnection();  // Which return database connection
```

### 3. Use Query Builder

[](#3-use-query-builder)

Now get database configs, create new instanse of `PDODatabaseConnection` and connect to DB.

```
$this->config = $this->getConfigs('database', 'astro_orm');

$pdoConnection = new PDODatabaseConnection($this->config);
$pdoHandler = $pdoConnection->connect();
```

#### Insert

[](#insert)

Insert Data: return last insert id

```
$data = [
    'name'  => 'John',
    'email' => 'john.doe@gmail.com',
    'link'  => 'https://example.com',
    'skill' => 'PHP'
];

$last_id = PDOQueryBuilder::table('users')->create($data);
```

#### update

[](#update)

Update Data: return true if successful

```
$result = PDOQueryBuilder::table('users')
    ->where('name', 'John')
    ->where('skill', 'PHP')
    ->update([
        'skill' => 'Javascript',
        'name' => 'Jeff',
        'email' => 'jeff@gmail.com'
    ]);
```

#### Multiple where

[](#multiple-where)

```
$result = PDOQueryBuilder::table('users')
    ->where('name', 'John')
    ->where('skill', 'JS')
    ->update(['skill' => 'Javascript']);
```

#### Multiple orWhere

[](#multiple-orwhere)

```
$result = PDOQueryBuilder::table('users')
    ->orWhere('skill', 'PHP')
    ->orWhere('skill', 'JS')
    ->get();
```

#### Delete

[](#delete)

Delete Data: return true if successful

```
$result = PDOQueryBuilder::table('users')
    ->where('name', 'John')
    ->delete();
```

#### Fetch

[](#fetch)

```
$result = PDOQueryBuilder::table('users')
    ->where('name', 'John')
    ->where('skill', 'Javascript')
    ->get();
```

#### Fetch first row

[](#fetch-first-row)

```
$result = PDOQueryBuilder::table('users')
    ->where('name', 'First Row')
    ->first();
```

#### Fetch first row or throw exception on failure

[](#fetch-first-row-or-throw-exception-on-failure)

```
$result = PDOQueryBuilder::table('users')
    ->where('name', 'Jim')
    ->firstOrFail();
```

#### Find ID

[](#find-id)

```
$result = PDOQueryBuilder::table('users')
    ->find($id);
```

#### Find ID or throw exception on failure

[](#find-id-or-throw-exception-on-failure)

```
$result = PDOQueryBuilder::table('users')
    ->findOrFail($id);
```

#### Find with value

[](#find-with-value)

```
$result = PDOQueryBuilder::table('users')
    ->findBy('name', 'Jack');
```

#### Get specific rows

[](#get-specific-rows)

```
$result = PDOQueryBuilder::table('users')
    ->where('name', 'Jack')
    ->limit(5)
    ->get();
```

#### Sort rows

[](#sort-rows)

```
$result = PDOQueryBuilder::table('users')
    ->orderBy('skill', 'DESC')
    ->get();
```

Testing
-------

[](#testing)

Run the tests with:

```
composer test
```

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

[](#contributing)

Contributions are welcome! To contribute, please familiarize yourself with [CONTRIBUTE.md](CONTRIBUTING.md)

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 97% 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 ~129 days

Recently: every ~18 days

Total

7

Last Release

901d ago

Major Versions

v1.2.0 → v2.0.02023-12-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/35e4e58889833b695c2c5b4e4c26be535803d06474a69e939de919a298f9f59f?d=identicon)[Rahimi](/maintainers/Rahimi)

---

Top Contributors

[![Mohammadreza-73](https://avatars.githubusercontent.com/u/22294125?v=4)](https://github.com/Mohammadreza-73 "Mohammadreza-73 (98 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (3 commits)")

---

Tags

databasefluent-apimysql-ormormpdo-phpphp-ormsqltdddatabaseormsqlfluent-interface

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mrahimi-astro-orm/health.svg)

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

###  Alternatives

[cycle/database

DBAL, schema introspection, migration and pagination

71777.8k53](/packages/cycle-database)[dbout/wp-orm

WordPress ORM with Eloquent.

12910.3k1](/packages/dbout-wp-orm)[agungsugiarto/codeigniter4-eloquent

The Illuminate Database package for CodeIgniter 4

264.5k](/packages/agungsugiarto-codeigniter4-eloquent)[bigsinoos/j-eloquent

Convert eloquent date attributes to jalali (Persian) dates on the fly. (supports model propery access, toJson, toString and toArray).

224.7k](/packages/bigsinoos-j-eloquent)

PHPackages © 2026

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