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

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

bronsted/orm
============

A simple orm for php

v4.2.1(1y ago)030[4 issues](https://github.com/sorenbronsted/orm/issues)MITPHPPHP ^7.4 || ~8.0

Since Nov 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sorenbronsted/orm)[ Packagist](https://packagist.org/packages/bronsted/orm)[ RSS](/packages/bronsted-orm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (13)Used By (0)

ORM
===

[](#orm)

This is a simple ORM database mapper which delivers some convenience methods to query, create and update objects. It does not support associations. Instead I use the convention that a foreign key is the name of the table appended '\_uid'. The only other convention is that an object must have a property named 'uid' and when you call save and the uid == 0 it will be converted to an insert statement otherwise it will be converted to an update statement.

It is a base on my older similar [package](https://packagist.org/packages/sbronsted/libdatabase) but with now you can use typed properties.

Installation
------------

[](#installation)

This package can be installed with [Composer](https://getcomposer.org/)

```
`composer install bronsted\orm`

```

Example
-------

[](#example)

Below is defined a Sample class

```
class Sample extends DbObject
{
    protected int $uid = 0;
    protected ?string $name = null;
    protected ?DateTime $created = null;
}
```

This class will have a corresponding table name sample where properties are columns.

As you se the properties are describe by types, which means that when the object is loaded from a table row, the columns are converted to the property type. In that way the date is not a string, but an date object with meaningful operation.

To create an object and persist it

```
$sample = new Sample();
$uid = $sample->save();
```

To to find one or more objects

```
// returns a single object
$sample = Sample::getByUid($uid);

// returns 0 or more objects
$samples = Sample::getBy(['name' => 'something%']);
```

To change a property and persist it

```
$sample = Sample::getByUid($uid);
$sample->name = 'Hello';
$sample->save();
```

To delete an object

```
$sample = Sample::getByUid($uid);
$sample->delete();
```

You also have access to the lower level database function in the DB class, which provides transformations for DbObject to sql or you can write the sql your self.

Configuration
-------------

[](#configuration)

The connection is done with plain php PDO.

```
$pdo = new PDO('sqlite::memory:');
$dbCon = new DbConnection($pdo);
Db::setConnection($dbCon);
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance40

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~103 days

Recently: every ~123 days

Total

12

Last Release

512d ago

Major Versions

v1.0 → v2.02022-01-04

v2.5 → v3.02023-08-19

v3.0 → v4.02023-09-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/e488c579b2d0961fd4d353c2f098f5c3d544721527c31e11d40f0978dc07c3ac?d=identicon)[sorenbronsted](/maintainers/sorenbronsted)

---

Top Contributors

[![sobrborsen](https://avatars.githubusercontent.com/u/72194780?v=4)](https://github.com/sobrborsen "sobrborsen (10 commits)")[![sorenbronsted](https://avatars.githubusercontent.com/u/2462997?v=4)](https://github.com/sorenbronsted "sorenbronsted (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

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