PHPackages                             foxtool/debra - 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. foxtool/debra

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

foxtool/debra
=============

Small ORM for the small projects

v1.0.0(4y ago)027MITPHP

Since Jan 24Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/FoxTool/Debra)[ Packagist](https://packagist.org/packages/foxtool/debra)[ RSS](/packages/foxtool-debra/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Debra
=====

[](#debra)

Simply ORM for the simply projects

The Database class is used for the database connection. This class is using the `"configs/database.php"` file with the next structure:

```
return [
    "host" => "localhost",
    "port" => 3306,
    "database" => "",
    "username" => "",
    "password" => ""
];
```

Basic example
-------------

[](#basic-example)

```
use FoxTool\Debra\EntityManager;
// User class, defined for example in the "app/Entity/User.php" file
use Debra\Entity\User;

// Create EntityManager instance
$em = new EntityManager();

// Set Model and return single object
$user = $em->setModel(User::class)->find(1);

// Display user login
echo $user->getLogin();

// Display the generated query text
$em->getQuery();
```

Examples:
---------

[](#examples)

*Find record by ID*
-------------------

[](#find-record-by-id)

```
use FoxTool\Debra\EntityManager;
// User class, defined for example in the "app/Entity/User.php" file
use Debra\Entity\User;

$em = new EntityManager();
$user = $em->setModel(User::class)->find(1);
```

*Find all records*
------------------

[](#find-all-records)

```
use FoxTool\Debra\EntityManager;
// User class, defined for example in the "app/Entity/User.php" file
use Debra\Entity\User;

$em = new EntityManager();
$users = $em->setModel(User::class)->all();
```

The method `all()` returns array of objects of the `User` class

*Find records by certain conditions*
------------------------------------

[](#find-records-by-certain-conditions)

```
use FoxTool\Debra\EntityManager;
// User class, defined for example in the "app/Entity/User.php" file
use Debra\Entity\User;

$em = new EntityManager();
$users = $em->setModel(User::class)->where([
    "login = :login",
    "password = :password",
    "role = :role"
])->setParams([
    "login" => "bob",
    "password" => "12345678",
    "role" => "author"
])->get();
```

The method `get()` returns array of objects of the `User` class

*Create new record*
-------------------

[](#create-new-record)

```
$em = new EntityManager();
$em->setModel(User::class);

$user = new User();
$user->setLogin('john');
$user->setPassword('12345678');
$user->setEmail('john.doe@gmail.com');
$user->setCreatedAt(date("Y-m-d H:i:s"));
$user->setUpdatedAt(date("Y-m-d H:i:s"));

$em->persist($user);
$em->save();
```

*Update record*
---------------

[](#update-record)

```
$em = new EntityManager();
$user = $em->setModel(User::class)->find(1);
$user->setLogin('john');
$user->setPassword('12345678');
$user->setEmail('john.doe@gmail.com');
$user->setCreatedAt(date("Y-m-d H:i:s"));
$user->setUpdatedAt(date("Y-m-d H:i:s"));

$em->persist($user);
$em->save();
```

*SELECT by fields list*
-----------------------

[](#select-by-fields-list)

```
// All fields (*)
$user = $this->em
    ->setModel(User::class)
    ->select('*')
    ->find($id);

// Fields defined as array
$user = $this->em
    ->setModel(User::class)
    ->select(['id', 'first_name', 'last_name'])
    ->find($id);

// Fields defined as string
$user = $this->em
    ->setModel(User::class)
    ->select('id, first_name, last_name, email')
    ->find($id);
```

*COUNT and SUM*
---------------

[](#count-and-sum)

```
// COUNT
$products = $this->em
    ->setModel(Product::class)
    ->count('total') // Result field name
    ->calculate();

// Can get value from the property which was sent as parameter in the "count" function
$products->total;

// SUM
$user = $this->em
    ->setModel(User::class)
    ->sum('id', 'total') // First is source field, second is result field
    ->calculate();

// Can get value from the property which was sent as second parameter in the "sum" function
$products->total;
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance42

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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

Unknown

Total

1

Last Release

1621d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7370392?v=4)[Volodymyr Zakharchenko](/maintainers/wildcorsair)[@Wildcorsair](https://github.com/Wildcorsair)

---

Top Contributors

[![Wildcorsair](https://avatars.githubusercontent.com/u/7370392?v=4)](https://github.com/Wildcorsair "Wildcorsair (12 commits)")[![zv-indev](https://avatars.githubusercontent.com/u/80040134?v=4)](https://github.com/zv-indev "zv-indev (7 commits)")[![FoxTool](https://avatars.githubusercontent.com/u/97512309?v=4)](https://github.com/FoxTool "FoxTool (5 commits)")

### Embed Badge

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

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

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