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 7mo ago1 watchersCompare

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

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

30

—

LowBetter than 64% of packages

Maintenance45

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

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

1574d ago

### Community

Maintainers

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

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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