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

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

switon/orm
==========

Typed entities, repository-first persistence, relation loading, and shard-aware routing for Switon Framework

v1.0.0(1mo ago)042MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 2mo agoCompare

[ Source](https://github.com/switon-php/orm)[ Packagist](https://packagist.org/packages/switon/orm)[ Docs](https://github.com/switon-php/orm)[ RSS](/packages/switon-orm/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (15)Versions (2)Used By (2)

Switon ORM Package
==================

[](#switon-orm-package)

[![ORM CI](https://camo.githubusercontent.com/5bb0c5ed244328c1e5409aeb7180b4807c5c24f5465f9064f0d9f88adf92abd8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f6f726d2f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4f524d2532304349)](https://github.com/switon-php/orm/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's entity mapping layer for attribute-driven models, repository queries, relations, lifecycle events, sharding-aware writes, and pagination boundaries.

Highlights
----------

[](#highlights)

- **Relationship mapping:** `Entity` classes declare linked records through attributes.
- **Relationship loading:** `RelationManager` handles eager and lazy loading.
- **Attribute-based mapping:** `Entity` classes declare tables, columns, IDs, and constraints through attributes.
- **Runtime-only properties:** `#[Transient]` keeps temporary fields out of persistence.
- **Repository queries:** `RepositoryInterface` and `Repository` cover filters, lookup, relation-backed reads, and pagination.
- **Safe write flow:** create and update paths include fill, validation, events, and `#[Transactional]` support.
- **Shard-safe writes:** writes resolve a single shard before they run.

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

[](#installation)

```
composer require switon/orm
```

Quick Start
-----------

[](#quick-start)

```
use Switon\Core\Attribute\Autowired;
use Switon\Orm\Attribute\{Id, Table, Transient};
use Switon\Orm\Entity;
use Switon\Orm\Page;
use Switon\Orm\Repository;

#[Table('users')]
class User extends Entity
{
    #[Id]
    public ?int $id = null;

    public string $name;

    public string $email;

    #[Transient]
    public ?string $displayName = null;
}

final class UserRepository extends Repository
{
}

final class UserController
{
    #[Autowired] protected UserRepository $userRepository;

    public function indexAction(Page $page): \Switon\Query\Paginator
    {
        return $this->userRepository->paginate($page);
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance87

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

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

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (9 commits)")

---

Tags

databaseentitymappingormrepositoryswitondatabaseormmappingrepositoriesentitiesswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[proesio/pipe

PIPE - ORM en Español.

149.7k1](/packages/proesio-pipe)[bauer01/unimapper

Universal mapping tool for collecting data from different sources

102.6k6](/packages/bauer01-unimapper)

PHPackages © 2026

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