PHPackages                             matthew-p/yii2-services - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. matthew-p/yii2-services

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

matthew-p/yii2-services
=======================

Extension provide very simply use services for models and controllers

3.1(6y ago)02.4k↓32.8%12MITPHPPHP ^7.1

Since Feb 22Pushed 6y ago1 watchersCompare

[ Source](https://github.com/MatthewPattell/yii2-services)[ Packagist](https://packagist.org/packages/matthew-p/yii2-services)[ RSS](/packages/matthew-p-yii2-services/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (2)

yii2-services
=============

[](#yii2-services)

Extension provide very simply use services for models and controllers

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist matthew-p/yii2-services "*"

```

or add

```
"matthew-p/yii2-services": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by:

Create service for model (must implement IService or extend any of services in MP\\Services):

```
use MP\Services\BaseModelService;

/**
 * ...
 *
 * @property SampleModel $model
 */
class MyCustomService extends BaseModelService
{
    /**
     * My simple method
     *
     * @return array
     */
    public function getSampleMethod(): array
    {
        return [];
    }
}
```

Create model:

```
...

use MP\Services\ImplementServices;

/**
 * Use services in model
 * ...
 *
 * Services
 * @property MyCustomService $customService
 */
class SampleModel extends ActiveRecord
{
    use ImplementServices;

    /**
     * @inheritdoc
     */
    public static function services(): array
    {
        return [
            'customService' => MyCustomService::class,
        ];
    }

    ...
}
```

And use:

```
$model = new SampleModel();
$model->customService->getSampleMethod();
```

For controllers, everything is the same, only the service is inherited from **BaseControllerService**

Tests
-----

[](#tests)

Run tests with command:

```
./vendor/bin/phpunit
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 81.8% 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 ~104 days

Recently: every ~127 days

Total

6

Last Release

2485d ago

Major Versions

1.2 → 2.02018-06-25

2.0 → 3.02018-08-11

PHP version history (3 changes)1.0PHP &gt;=7.0

2.0PHP &gt;=7.1

3.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/624ecdaa0fb10377abf846c22f1292f5dfc6b1a9277b3e239e323733565ae241?d=identicon)[hellboymxb@gmail.com](/maintainers/hellboymxb@gmail.com)

---

Top Contributors

[![k-timoshenko](https://avatars.githubusercontent.com/u/3259675?v=4)](https://github.com/k-timoshenko "k-timoshenko (18 commits)")[![MatthewPattell](https://avatars.githubusercontent.com/u/10459911?v=4)](https://github.com/MatthewPattell "MatthewPattell (4 commits)")

---

Tags

modelyii2extensioncontrollerservices

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/matthew-p-yii2-services/health.svg)

```
[![Health](https://phpackages.com/badges/matthew-p-yii2-services/health.svg)](https://phpackages.com/packages/matthew-p-yii2-services)
```

###  Alternatives

[vyants/yii2-daemon

Extension provides functionality for simple daemons creation and control

7859.0k](/packages/vyants-yii2-daemon)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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