PHPackages                             yunbuye/thinkphp-facade - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. yunbuye/thinkphp-facade

ActiveLibrary[Testing &amp; Quality](/categories/testing)

yunbuye/thinkphp-facade
=======================

ThinkPHP 方便被 mock 的 facade

0.8.2(6y ago)1651[1 PRs](https://github.com/yunbuye/thinkphp-facade/pulls)MITPHPPHP &gt;=5.6.0

Since Dec 25Pushed 3y ago2 watchersCompare

[ Source](https://github.com/yunbuye/thinkphp-facade)[ Packagist](https://packagist.org/packages/yunbuye/thinkphp-facade)[ Docs](http://github.com/yunbuye/thinkphp-facade)[ RSS](/packages/yunbuye-thinkphp-facade/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

ThinkPHP 方便被 mock 的 facade
==========================

[](#thinkphp-方便被-mock-的-facade)

安装
--

[](#安装)

非开发依赖，不要加--dev

```
composer require yubuye/thinkphp-facade
```

自定义的所有Facade必须继承 Yunbuye\\ThinkFacade\\Facade。

使用
--

[](#使用)

1. 安装开发依赖

```
composer require mockery/mockery --dev
```

1. 使用此扩展包后 mock 方式
    例：MyFacade

```
MyFacade::shouldReceive('get')
      ->once()
      ->with('key')
      ->andReturn('value');
MyFacade::get('key')=='value'//true
```

1. 框架自带 Facade 及 其他没有继承 Yunbuye\\ThinkFacade\\Facade 的 Facade 的 mock 方式
    例： 缓存Cache的模拟

```
use Mockery;
use Mockery\Mock;
//先找到 Cache 对应的绑定实现类 think\Cache ，并对其进行模拟
 $mock=Mockery::mock('think\Cache', function ($mock) {
    /**
     * @var Mock $mock
     */
    $return='return';
    $key='key';
    return $mock->shouldReceive('get')->with($key)->andReturn($return);
});
Container::getInstance()->bindTo('think\Cache',$mock);
//模拟后，即 Cache Facade 也被模拟
Cache::get('key')=='return'//true
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~7 days

Total

3

Last Release

2321d ago

### Community

Maintainers

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

---

Top Contributors

[![xwpd](https://avatars.githubusercontent.com/u/17465049?v=4)](https://github.com/xwpd "xwpd (10 commits)")

---

Tags

facademockthinkphp5mockerymockfacadethinkphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yunbuye-thinkphp-facade/health.svg)

```
[![Health](https://phpackages.com/badges/yunbuye-thinkphp-facade/health.svg)](https://phpackages.com/packages/yunbuye-thinkphp-facade)
```

###  Alternatives

[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brain/monkey

Mocking utility for PHP functions and WordPress plugin API

33412.5M350](/packages/brain-monkey)[polishsymfonycommunity/symfony-mocker-container

Provides base Symfony dependency injection container enabling service mocking.

1468.0M237](/packages/polishsymfonycommunity-symfony-mocker-container)[php-mock/php-mock

PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed.

36918.1M98](/packages/php-mock-php-mock)[php-mock/php-mock-mockery

Mock built-in PHP functions (e.g. time()) with Mockery. This package relies on PHP's namespace fallback policy. No further extension is needed.

392.1M96](/packages/php-mock-php-mock-mockery)

PHPackages © 2026

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