PHPackages                             chenqd/mixin - 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. chenqd/mixin

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

chenqd/mixin
============

mixin for php

0.3.1(9y ago)0281PHP &gt;=5.5.9

Since Apr 11Compare

[ Source](https://github.com/chenqd/mixin)[ Packagist](https://packagist.org/packages/chenqd/mixin)[ RSS](/packages/chenqd-mixin/feed)WikiDiscussions Synced 6d ago

READMEChangelogDependencies (2)Versions (2)Used By (1)

\#mixin 这是一个php的简单mixin实现 参考yii中behavior中的实现其实没能避免多继承的缺陷： 优先顺序模糊、继承方法不明确。 其实就技术实现来说并没有太大的难点，这里提供的就是给mixin别名并通过别名调用的方式。

为开发便利引入了一些laravel的组件，感谢laravel作者的优良设计

使用
--

[](#使用)

main class

```
use chenqd\mixin\HasMixin;

class User {
    use HasMixin;
    public $name ='shoal';

    public function mixinMap()
    {
        return [
            'cook' => Cook::class,
            'aa'=> [
                'bb' => Cook::class,
            ],
            'aa.cc'=> [
                Cook2::class,
                'food'=>'大饼'
            ],
        ];
    }
}
```

mixin class

```
use chenqd\mixin\MixinTrait;

class Cook {
    use MixinTrait;
    public function done(){
        echo $this->name . " cook a lot of delicious food!\n";
    }
}

class Cook2 {
    use MixinTrait;
    public $food;
    public function __construct($entity, $food){
        $this->entity = $entity;
        $this->food = $food;
    }

    public function done(){
        //do something
        echo $this->name . ' cook a '.$this->food."!\n";
        //do something
    }
}
```

调用

```
$user = new User();
$user->mixinCall('cook')->done();
$user->mixinCall('aa.bb', 'done');
$user->mixinCall('aa.cc', 'done');
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

3413d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6767197?v=4)[chenqd](/maintainers/chenqd)[@chenqd](https://github.com/chenqd)

### Embed Badge

![Health badge](/badges/chenqd-mixin/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[illuminate/events

The Illuminate Events package.

13558.0M2.3k](/packages/illuminate-events)[illuminate/database

The Illuminate Database package.

2.8k55.8M13.0k](/packages/illuminate-database)[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M307](/packages/laravel-ai)[illuminate/broadcasting

The Illuminate Broadcasting package.

7127.4M234](/packages/illuminate-broadcasting)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

79227.1M218](/packages/laravel-mcp)

PHPackages © 2026

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