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 2d 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

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

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

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