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 today

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 69% of packages

Maintenance38

Infrequent updates — may be unmaintained

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

557d ago

Major Versions

v1.0 → v2.02022-01-04

v2.5 → v3.02023-08-19

v3.0 → v4.02023-09-01

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2462997?v=4)[Søren Brønsted](/maintainers/sorenbronsted)[@sorenbronsted](https://github.com/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

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