PHPackages                             haohetao/php-console-yii2 - 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. haohetao/php-console-yii2

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

haohetao/php-console-yii2
=========================

PhpConsole wrapper for Yii2

1763↓100%1PHP

Since Aug 21Pushed 5y ago1 watchersCompare

[ Source](https://github.com/haohetao/php-console-yii2)[ Packagist](https://packagist.org/packages/haohetao/php-console-yii2)[ RSS](/packages/haohetao-php-console-yii2/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

php-console-yii2
================

[](#php-console-yii2)

PhpConsole wrapper for Yii 2

Based on

安装
==

[](#安装)

### Composer

[](#composer)

```
{
	"require": {
		"haohetao/php-console": "dev-master"
	}
}

```

Or

```
$ composer require haohetao/php-console-yii2 dev-master

```

Configuration Example
=====================

[](#configuration-example)

```
Into common/main.php
'bootstrap' => ['phpconsole'],
'components' => [
    'phpconsole' => [
        'class' => '\haohetao\PhpConsole\PhpConsole',
        'isEnabled' => true,
        'ipMasks'=>['192.168.*.*', '2001:0:5ef5:79fb:*:*:*:*'],
        'handleErrors'=>true,//处理错误
        'handleExceptions'=>true,//处理异常
        'callOldHandlers'=>true,//是否调用yii自带的错误处理
        'discardExistingOutput'=>false//这个是配置yii的错误处理的，设置是否同时输出多个处理器的错误，为true的话只输出最后一个处理器的错误
    ],
]

```

Usage
=====

[](#usage)

```
public function actionIndex()
{
    \PC::debug('ok');
    return $this->render('index');
}

```

也可以自定义全局函数
==========

[](#也可以自定义全局函数)

```
/**
 * 使用phpconsole打印调试信息
 * @param $var
 * @param null $tags
 */
function d($var, $tags = null) {
    $phpConsole=Yii::$app->phpconsole;
    if(!$phpConsole->isEnabled)
    {
        return;
    }
    $inst=PhpConsole\Connector::getInstance();
    if($inst && $inst->isActiveClient())
    {
        $inst->getDebugDispatcher()->dispatchDebug($var, $tags);
    }
}

```

加载全局函数 在项目根目录的composer.json中加入

```
    "autoload": {
        "files": [
            "common/components/GlobalFunctions.php"
        ]
    }

```

然后

```
composer install

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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/49ee9003109866ee01a052ac1c956a4302217912349bac7c43c297647b3694f3?d=identicon)[haohetao](/maintainers/haohetao)

---

Top Contributors

[![haohetao](https://avatars.githubusercontent.com/u/4592571?v=4)](https://github.com/haohetao "haohetao (13 commits)")[![nvanderburg](https://avatars.githubusercontent.com/u/73654874?v=4)](https://github.com/nvanderburg "nvanderburg (8 commits)")[![ASolomatin](https://avatars.githubusercontent.com/u/10348041?v=4)](https://github.com/ASolomatin "ASolomatin (5 commits)")[![nilsburg](https://avatars.githubusercontent.com/u/1023621?v=4)](https://github.com/nilsburg "nilsburg (2 commits)")

### Embed Badge

![Health badge](/badges/haohetao-php-console-yii2/health.svg)

```
[![Health](https://phpackages.com/badges/haohetao-php-console-yii2/health.svg)](https://phpackages.com/packages/haohetao-php-console-yii2)
```

###  Alternatives

[stingbo/easyexchange

easy use digital currency exchange sdk

871.3k](/packages/stingbo-easyexchange)

PHPackages © 2026

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