PHPackages                             michalwolinski/unit-of-work - 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. michalwolinski/unit-of-work

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

michalwolinski/unit-of-work
===========================

Unit of Work (Entity Manager) design pattern Laravel implementation.

40PHPCI failing

Since Feb 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/michalwolinski/unit-of-work)[ Packagist](https://packagist.org/packages/michalwolinski/unit-of-work)[ RSS](/packages/michalwolinski-unit-of-work/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Unit of Work for Laravel
========================

[](#unit-of-work-for-laravel)

Unit of Work (Entity Manager) design pattern Laravel implementation.

---

Installation by Composer
------------------------

[](#installation-by-composer)

1. Run ```
    composer require michalwolinski/unit-of-work
    ```

    in console to install this library.

---

Usage
-----

[](#usage)

I propose to use Dependency Injection to inject `UnitOfWorkInterface`.

Example implementation in service class:

```
use App\User;
use MichalWolinski\UnitOfWork\Interfaces\UnitOfWorkInterface;

class Service {

    /**
     * @var UnitOfWorkInterface
     */
    private UnitOfWorkInterface $unitOfWork;

    public function __construct(UnitOfWorkInterface $unitOfWork)
    {
        $this->unitOfWork = $unitOfWork;
    }

    public function example()
    {
        $user           = new User();
        $user->email    = 'firma@haxmedia.pl';
        $user->name     = 'Michal Wolinski';
        $user->password = 'secret';

        $user2           = new User();
        $user2->email    = 'example@company.com';
        $user2->name     = 'John Doe';
        $user2->password = 'secret';

        // CREATE RECORDS
        $this->unitOfWork->insert($user);
        $this->unitOfWork->insert($user2);
        $this->unitOfWork->commit();

        dump($user2->getKey());

        // UPDATE RECORDS
        $user2->name = 'Jane Doe';
        $this->unitOfWork->update($user2);
        $this->unitOfWork->commit();

        // REMOVE RECORDS
        $this->unitOfWork->delete($user2);
        $this->unitOfWork->commit();
    }
}
```

Authors
-------

[](#authors)

- **Michal Wolinski** - [Haxmedia](https://haxmedia.pl)

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/58229155?v=4)[Michał Woliński](/maintainers/michalwolinski)[@michalwolinski](https://github.com/michalwolinski)

---

Top Contributors

[![michalwolinski](https://avatars.githubusercontent.com/u/58229155?v=4)](https://github.com/michalwolinski "michalwolinski (1 commits)")

### Embed Badge

![Health badge](/badges/michalwolinski-unit-of-work/health.svg)

```
[![Health](https://phpackages.com/badges/michalwolinski-unit-of-work/health.svg)](https://phpackages.com/packages/michalwolinski-unit-of-work)
```

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