PHPackages                             dekeysoft/yii2-domain - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. dekeysoft/yii2-domain

Abandoned → [https://github.com/php-kitchen/yii2-domain](/?search=https%3A%2F%2Fgithub.com%2Fphp-kitchen%2Fyii2-domain)Library[File &amp; Storage](/categories/file-storage)

dekeysoft/yii2-domain
=====================

Implementation of DDD key concepts for Yii2.

v0.0.35(6y ago)333966[12 issues](https://github.com/dekeysoft/yii2-domain/issues)[1 PRs](https://github.com/dekeysoft/yii2-domain/pulls)MITPHPPHP ^7.1CI failing

Since Feb 3Pushed 6y ago7 watchersCompare

[ Source](https://github.com/dekeysoft/yii2-domain)[ Packagist](https://packagist.org/packages/dekeysoft/yii2-domain)[ RSS](/packages/dekeysoft-yii2-domain/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (5)Versions (45)Used By (0)

 [![](https://github.com/php-kitchen/yii2-domain/raw/master/docs/logo.png)](https://github.com/php-kitchen/yii2-domain/blob/master/docs/logo.png)

 [![Build Status](https://camo.githubusercontent.com/847d989095fbba5d3ab4d60260eac7a7856c9e59c81d481e0e31532827533eda/68747470733a2f2f6170702e62756464792e776f726b732f7068702d6b69746368656e2f796969322d646f6d61696e2f706970656c696e65732f706970656c696e652f3232353831382f62616467652e7376673f746f6b656e3d62316133393662633033303230613632343530646363656561663635326465353663323837353933633561383939313535626663616234623635636535363431)](https://app.buddy.works/php-kitchen/yii2-domain/pipelines) [![Tested By](https://camo.githubusercontent.com/6bae54c064c6ed56905bbb9b8589c78a560988f7b5d3f4adaf6f72d305a44230/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5465737465645f42792d436f646553706563732d627269676874677265656e2e737667)](https://github.com/php-kitchen/code-specs) [![](https://camo.githubusercontent.com/80446f8ed02d55c0f233b395a26402e10509ffc8f4b4849aba50dba7774b1edf/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f30616630323138373438386430643264373061642f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/php-kitchen/yii2-domain/maintainability) [![Latest Stable Version](https://camo.githubusercontent.com/cbf89b218a76c0060cb1b3f455b67b9f48891da360f0e5427795cbe7cee8fe7d/68747470733a2f2f706f7365722e707567782e6f72672f7068702d6b69746368656e2f796969322d646f6d61696e2f762f737461626c652e737667)](https://packagist.org/packages/php-kitchen/yii2-domain) [![Monthly Downloads](https://camo.githubusercontent.com/d082de9a7314755a0c192d617197d4421d161c561bc5dbaab25c6b25910f5020/68747470733a2f2f706f7365722e707567782e6f72672f7068702d6b69746368656e2f796969322d646f6d61696e2f642f6d6f6e74686c79)](https://packagist.org/packages/php-kitchen/yii2-domain) [![Total Downloads](https://camo.githubusercontent.com/7548ae3f689e315aa1336e9b263a392372c5652d3876c32df246179b9dee21dd/68747470733a2f2f706f7365722e707567782e6f72672f7068702d6b69746368656e2f796969322d646f6d61696e2f642f746f74616c2e737667)](https://packagist.org/packages/php-kitchen/yii2-domain) [![License](https://camo.githubusercontent.com/221b4e73b6b788921e55501e55bf6858ac78d63fcc6f28c1a56563f83c26f637/68747470733a2f2f706f7365722e707567782e6f72672f7068702d6b69746368656e2f796969322d646f6d61696e2f6c6963656e73652e737667)](https://packagist.org/packages/php-kitchen/yii2-domain)

**Yii2 Domain** is a Domain Driven Design patterns implementation for Yii2.

Includes realization of a following patterns:

- Repository
- Entity
- Specification (very rough implementation through ActiveQuery)
- Strategy

Requirements
------------

[](#requirements)

**`PHP >= 7.1` is required.**

Getting Started
---------------

[](#getting-started)

Run the following command to add Yii2 Domain to your project's `composer.json`. See [Packagist](https://packagist.org/packages/php-kitchen/yii2-domain) for specific versions.

```
composer require php-kitchen/yii2-domain
```

Or you can copy this library from:

- [Packagist](https://packagist.org/packages/php-kitchen/yii2-domain)
- [Github](https://github.com/php-kitchen/yii2-domain)

For additional information and guides go to the [project documentation](docs/README.md)

Overview
--------

[](#overview)

Goal of this library is to introduce Domain Driven Design(DDD) principles to Yii2 projects and to fix [ActiveRecord problem](http://www.mehdi-khalili.com/orm-anti-patterns-part-1-active-record)of domain layer in applications with medium and large domain area.

Each model represented as a standalone directory that contains repository, entity, record and query classes. All of these classes represent a domain model.

DIRECTORY STRUCTURE OF A TYPICAL MODEL(AS EXAMPLE - USER MODEL)
---------------------------------------------------------------

[](#directory-structure-of-a-typical-modelas-example---user-model)

```
  user/                    contains all of the classes that represents domain model
        UserRepository     model repository
        UserEntity         model entity(represents domain entity - not the DB table that containd entity information)
        UserRecord         DB record that contains entity information
        ProfileRecord      DB record with additional information thta also a part of the UserEntity.
        UserQuery          query class of model e.g. - specification of the entity

```

Code examples
-------------

[](#code-examples)

Simple search and store:

```
$repository = new UserRepository();
$entity = $repository->findOneWithPk(1);
// do some manipulations with entity
$repository->validateAndSave($entity);
```

Complex criteria search and deleting:

```
$repository = new UserRepository();
$entity = $repository->find()
		->active()
		->withoutEmail()
		->one();
// do some manipulations with entity
$repository->delete($entity);
```

Note:
-----

[](#note)

this library is designed to solve [ActiveRecord problem](http://www.mehdi-khalili.com/orm-anti-patterns-part-1-active-record) of Yii 2. Don't use this library if you are starting a new project and looking for a solution that would allow you to build a decent architecture - you need a good framework that would allow you do build high-quality solution and Yii 2 is not a framework that would allow you to build high quality architecture and implement rich domain layer.

"Yii2Domain" library is a crutch designed to solve issues of domain layer caused by ActiveRecord in existing projects. There are few decent solutions to build domain layer in a new project:

- [Spot ORM](http://phpdatamapper.com/)
- [Symfony + Doctrine](http://symfony.com/doc/current/doctrine.html) (preferable solution)
- [Eloquent ORM](http://laravel.su/docs/5.4/eloquent) (if you like Laravel and you are not working with enterprise applications)

Contributing
------------

[](#contributing)

If you want to ask any questions, suggest improvements or just to talk with community and developers, [join our server at Discord](https://discord.gg/Ez5VZhC)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 76.7% 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 ~31 days

Recently: every ~40 days

Total

37

Last Release

2259d ago

PHP version history (2 changes)0.0.0PHP ^5.6|^7.0

v0.0.19PHP ^7.1

### Community

Maintainers

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

---

Top Contributors

[![prowwid](https://avatars.githubusercontent.com/u/3070281?v=4)](https://github.com/prowwid "prowwid (69 commits)")[![dmitrybukavin](https://avatars.githubusercontent.com/u/186560148?v=4)](https://github.com/dmitrybukavin "dmitrybukavin (8 commits)")[![gh0ti](https://avatars.githubusercontent.com/u/14825981?v=4)](https://github.com/gh0ti "gh0ti (4 commits)")[![alexkart](https://avatars.githubusercontent.com/u/8249105?v=4)](https://github.com/alexkart "alexkart (3 commits)")[![Djaconda](https://avatars.githubusercontent.com/u/12255686?v=4)](https://github.com/Djaconda "Djaconda (2 commits)")[![avicberbf](https://avatars.githubusercontent.com/u/186559195?v=4)](https://github.com/avicberbf "avicberbf (2 commits)")[![DeathAngel](https://avatars.githubusercontent.com/u/24628192?v=4)](https://github.com/DeathAngel "DeathAngel (1 commits)")[![miguelbemartin](https://avatars.githubusercontent.com/u/1125116?v=4)](https://github.com/miguelbemartin "miguelbemartin (1 commits)")

---

Tags

specificationentityfinderyii2Domain Driven Designclean coderepositorydddstrategy

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dekeysoft-yii2-domain/health.svg)

```
[![Health](https://phpackages.com/badges/dekeysoft-yii2-domain/health.svg)](https://phpackages.com/packages/dekeysoft-yii2-domain)
```

###  Alternatives

[php-kitchen/yii2-domain

Implementation of DDD key concepts for Yii2.

332.2k](/packages/php-kitchen-yii2-domain)[liyunfang/yii2-upload-behavior

Upload behavior for Yii 2

161.7k](/packages/liyunfang-yii2-upload-behavior)

PHPackages © 2026

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