PHPackages                             niroee/easy-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. niroee/easy-orm

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

niroee/easy-orm
===============

A simple and lightweight php ORM

10PHP

Since Feb 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/miladniroee/easy-orm)[ Packagist](https://packagist.org/packages/niroee/easy-orm)[ RSS](/packages/niroee-easy-orm/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

PHP easy ORM
============

[](#php-easy-orm)

**Easy ORM** is a simple and lightweight PHP database class.

Installation
============

[](#installation)

using composer:

```
composer require niroee/easy-orm

```

Usage
=====

[](#usage)

You can use this orm for CRUD from one table.

First you should make a class that extends `Niroee\EasyOrm` :

```
use Niroee\EasyOrm\Model;

class Users extends Model{}
```

> For every table you have to make a specific model. for example `Users` class points to `users` table and `UserAddresses` points to `user_addresses` table.

### Making model with custom table name

[](#making-model-with-custom-table-name)

you can define in your class by passing `$table` attribute to your class:

```
use Niroee\EasyOrm\Model;

class OtherTable extends Model
{
  protected string|null $Table = "users";
}
```

### Access to model

[](#access-to-model)

```
$Users = Users::get(); // return all users

// or

$UsersInstance = new Users();
[$Users = $UsersInstance->get(); // return all users]()
```

You have to use `get()`, `first()`,`json()`,`toArray()` method for select and `exec()` method for insert, update and delete query.

#### get()

[](#get)

return all entries;

```
$Users = Users::get(); // return all users
$FirstUserName = $Users[0]->name;
```

#### first()

[](#first)

return first entry;

```
$User = Users::first()->name; // return name of first user
```

#### json()

[](#json)

return all entries as json serialized string;

```
$Users = Users::json(); // return json string
```

#### toArray()

[](#toarray)

return all entries as an array (nested-array);

```
$Users = Users::toArray();
$FirstUserName = $Users[0]['name'];
```

if you want to update, insert or delete entries, you have to use `exec()` method after you query.

```
Users::insert(['name' => 'milad'])->exec();

Users::update(['name' => 'ali'])->where('name', '=', 'milad')->exec();

Users::delete()->where('name', '=', 'ali')->exec();
```

if you want to see query, you can use `query()` method;

```
Users::query(); // SELECT * FROM `users`

Users::insert(['name' => 'milad'])->query(); // INSERT INTO users(name) VALUES(?)
```

---

Conditions
----------

[](#conditions)

if you want to specify condition for queries, you can use `where()`,`andWhere()` and `orWhere()` methods.

```
Users::update(['name' => 'milad',])
->where('id', '=', 2)
->exec();

//or

Users::update(['name' => 'milad'])
->where('id', '=', 2)
->andWhere('name', '=', 'ali')
->orWhere('id', '=', 1)
->exec();
```

These three methods accepts three arguments:

- Column: string
- Operator: string
- Value: mixed

```
where($Column, $Operator, $Value)
```

Select
------

[](#select)

For Select all columns (`*`) you can call `get()`, `first()`,`json()` or `toArray()` method;

```
$Users = Users::get(); // return all users
```

you can specify column to return from table.

```
Users::select('name')->get(); // return all users name

// or

Users::select(['name','id'])->get(); // return all users name and id
```

Update
------

[](#update)

update method accepts array contains key =&gt; value fo update from table

```
Users::update([
    'name' => 'milad',
    'app_id' => 5
])->exec(); // will return count of row affected

```

you can use conditions to update rows:

```
Users::update(['name' => 'milad',])
->where('id', '=', 2)
->exec(); // will return count of row affected
```

Insert
------

[](#insert)

insert method accepts array for inserting by key =&gt; value

```
Users::insert([
    'name' => 'milad',
    'app_id' => 5
])->exec(); // will return count of row affected
```

Delete
------

[](#delete)

delete method would remove selected rows.

```
Users::delete()->exec(); // delete all rows

// or

Users::delete()->where('id', '=', 5)->exec(); // delete user with id = 5
```

###  Health Score

14

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 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://www.gravatar.com/avatar/b43453ff8334922ec6191af6b0210c7732b9c1b2139c02498b8b4d5b80515bea?d=identicon)[miladniroee](/maintainers/miladniroee)

---

Top Contributors

[![miladniroee](https://avatars.githubusercontent.com/u/67730126?v=4)](https://github.com/miladniroee "miladniroee (2 commits)")

### Embed Badge

![Health badge](/badges/niroee-easy-orm/health.svg)

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

###  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)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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