PHPackages                             haohetao/php-console - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. haohetao/php-console

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

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

PHP library for Google Chrome extension "PHP Console".

3.1.8(6y ago)0668↓100%MITPHPPHP &gt;=5.3.0

Since Dec 24Pushed 5y agoCompare

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

READMEChangelogDependencies (2)Versions (13)Used By (0)

PHP Console server library
==========================

[](#php-console-server-library)

[![Author](https://camo.githubusercontent.com/f18fdab5c2556c2a0d2b9a31b5dd50f9fa32ff758343d74601b0a744cd12c6db/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d4062617262757368696e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://www.linkedin.com/in/barbushin)[![GitHub release](https://camo.githubusercontent.com/86d5450d663d569c4643476e9d1edd9fe56f4f1bd4259e4d1e793a6c783dfa4e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62617262757368696e2f7068702d636f6e736f6c652e7376673f6d61784167653d32353932303030267374796c653d666c61742d737175617265)](https://packagist.org/packages/php-console/php-console)[![Coverage Status](https://camo.githubusercontent.com/1df71072d02c1b58b194638b9dbcaa28d1044f1947788fdafe92c8c497c2a4c6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f62617262757368696e2f7068702d636f6e736f6c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/barbushin/php-console/code-structure)[![Build Status](https://camo.githubusercontent.com/78d74ac70bc70afb559bfc0c7f069447ddcaf2ed4fa5c215ac6ba259ff51ccf6/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f62617262757368696e2f7068702d636f6e736f6c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/barbushin/php-console)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist](https://camo.githubusercontent.com/c9727343cad1fe4adc03e3bfcc9e3af520c26a333aafe4205ebadab9dfb24197/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068702d636f6e736f6c652f7068702d636f6e736f6c652e7376673f6d61784167653d3836343030267374796c653d666c61742d737175617265)](https://packagist.org/packages/php-console/php-console)

PHP Console allows you to handle PHP errors &amp; exceptions, dump variables, execute PHP code remotely and many other things using [Google Chrome extension PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef) and [PhpConsole server library](https://github.com/barbushin/php-console).

### Overview

[](#overview)

- See [presentation video](http://www.youtube.com/watch?v=_4kG-Zrs2Io).
- Install Google Chrome extension [PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef).
- See how it works on [live demo](http://consle.com/instance/examples) page.
- PHP Console extension [features list and screenshots](https://github.com/barbushin/php-console/wiki/PHP-Console-extension-features).
- PHP Console server library [features list](https://github.com/barbushin/php-console/wiki/PHP-Console-server-features).
- Chrome extension source code

### Requirements

[](#requirements)

- [PHP Console extension](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef) must be installed on Google Chrome ([extension source code](https://github.com/barbushin/php-console-extension) is also on GitHub)
- PHP 5.3 (or later) on server.

*For projects with PHP &lt; 5.3 you can try to use old [deprecated version](https://groups.google.com/forum/?hl=ru#!forum/php-console-deprecated-version) of PHP Console. But mention that actual last version is much more functional.*

Installation
============

[](#installation)

### Composer

[](#composer)

```
{
	"require": {
		"php-console/php-console": "^3.1"
	}
}

```

Or

```
$ composer require php-console/php-console

```

### Monolog handler

[](#monolog-handler)

### Symfony framework bundle

[](#symfony-framework-bundle)

### Yii framework extension

[](#yii-framework-extension)

### Slim framework

[](#slim-framework)

 (thanks to [@amenadiel](https://github.com/amenadiel))

### Silex framework service provider

[](#silex-framework-service-provider)

 (thanks to [@Chi-teck](https://github.com/Chi-teck))

### Laravel 4.\* &amp; 5.\* framework service provider

[](#laravel-4--5-framework-service-provider)

### Drupal CMS module

[](#drupal-cms-module)

 (thanks to [@Chi-teck](https://github.com/Chi-teck))

### WordPress plugin

[](#wordpress-plugin)

 (thanks to [@nekojira](https://github.com/unfulvio))

Usage
=====

[](#usage)

You can try most of PHP Console features on [live demo](http://consle.com/instance/examples) server.

Connector
---------

[](#connector)

There is a [PhpConsole\\Connector](src/PhpConsole/Connector.php) class that initializes connection between PHP server and Google Chrome extension. Connection is initialized when [PhpConsole\\Connector](src/PhpConsole/Connector.php) instance is initialized:

```
$connector = PhpConsole\Connector::getInstance();

```

Also it will be initialized when you call `PhpConsole\Handler::getInstance()` or `PhpConsole\Helper::register()`.

### Communication protocol

[](#communication-protocol)

PHP Console uses headers to communicate with client, so `PhpConsole\Connector::getInstance()` or `PhpConsole\Handler::getInstance()` must be called before any output. If headers are sent before script shut down or PHP Console response package size is out of web-server headers size limit, then PHP Console will store response data in [PhpConsole\\Storage](src/PhpConsole/Storage.php) implementation and send it to client in STDOUT, in additional HTTP request. So there is no limit in PHP Console response package size.

### Troubleshooting with $\_SESSION handler overridden in some frameworks

[](#troubleshooting-with-_session-handler-overridden-in-some-frameworks)

By default PHP Console uses [PhpConsole\\Storage\\Session](src/PhpConsole/Storage/Session.php) for postponed responses, so all temporary data will be stored in `$_SESSION`. But there is some problem with frameworks like [Symfony](http://symfony.com) and [Laravel](http://laravel.com) that overrides PHP session handler. In this case you should use any other [PhpConsole\\Storage](src/PhpConsole/Storage.php) implementation like:

```
// Can be called only before PhpConsole\Connector::getInstance() and PhpConsole\Handler::getInstance()
PhpConsole\Connector::setPostponeStorage(new PhpConsole\Storage\File('/tmp/pc.data'));

```

See all available [PhpConsole\\Storage](src/PhpConsole/Storage.php) implementations in [/src/PhpConsole/Storage](src/PhpConsole/Storage).

### Strip sources base path

[](#strip-sources-base-path)

If you want to see errors sources and traces paths more short, call:

```
$connector->setSourcesBasePath('/path/to/project');

```

So paths like `/path/to/project/module/file.php` will be displayed on client as `/module/file.php`.

### Works with different server encodings

[](#works-with-different-server-encodings)

If your internal server encoding is not UTF-8, so you need to call:

```
$connector->setServerEncoding('CP1251');

```

### Initialization performance

[](#initialization-performance)

PhpConsole server library is optimized for lazy initialization only for clients that have Google Chrome extension PHP Console installed. There is [example](examples/features/highload_optimization.php) of correct initialization PhpConsole on your production server.

Protect connection
------------------

[](#protect-connection)

### Protect by password

[](#protect-by-password)

[![ScreenShot](https://camo.githubusercontent.com/8d84d5e4e3f42b988dbd4d954cfc62f59ec3fb1f6ae0d747db40d5c6f7a92871/687474703a2f2f636f6e736c652e636f6d2f7265732f73637265656e73686f742f617574685f3432302e706e67)](http://consle.com/instance/examples/#protect_by_password)

```
$connector->setPassword('yohoho123', true);

```

Clients will need to enter a password to get access to PHP Console server data. All passwords are stored on client as SHA-256 hashes. Second argument says that the PHP Console authorization token will depend on the client IP.

### SSL only connection mode

[](#ssl-only-connection-mode)

```
$connector->enableSslOnlyMode();

```

So all PHP Console clients will be automatically redirected to HTTPS.

### Protect connection by list of allowed IP masks

[](#protect-connection-by-list-of-allowed-ip-masks)

```
$connector->setAllowedIpMasks(array('192.168.*.*', '2001:0:5ef5:79fb:*:*:*:*'));

```

Handle errors
-------------

[](#handle-errors)

[![ScreenShot](https://camo.githubusercontent.com/4e518c772f849c883d5ae9a98ec26a4f791735ed253218ad932387e3bb61f3b8/687474703a2f2f636f6e736c652e636f6d2f7265732f73637265656e73686f742f6572726f72735f3432302e706e67)](http://consle.com/instance/examples/#handle_errors)

There is a [PhpConsole\\Handler](src/PhpConsole/Handler.php) class that initializes PHP errors &amp; exceptions handlers and provides the next features:

- Handle PHP errors (+fatal &amp; memory limit errors) and exceptions.
- Ignore repeated errors.
- Call previously defined errors and exceptions handlers.
- Handle caught exceptions using `$handler->handleException($exception)`.
- Debug vars using `$handler->debug($var, 'some.tags')`.

Initialize `PhpConsole\Handler` in the top of your main project script:

```
$handler = PhpConsole\Handler::getInstance();
/* You can override default Handler behavior:
	$handler->setHandleErrors(false);  // disable errors handling
	$handler->setHandleExceptions(false); // disable exceptions handling
	$handler->setCallOldHandlers(false); // disable passing errors & exceptions to prviously defined handlers
*/
$handler->start(); // initialize handlers

```

Debug vars
----------

[](#debug-vars)

[![ScreenShot](https://camo.githubusercontent.com/781f871b3c627c69b1369bde9f0f2ae4517e57dba2caee8a105cc2b0ac9c012d/687474703a2f2f636f6e736c652e636f6d2f7265732f73637265656e73686f742f64656275675f3432302e706e67)](http://consle.com/instance/examples/#debug_vars)

PHP Console has multifunctional and smart vars dumper that allows to

- Dump any type variable.
- Dump protected and private objects properties.
- Limit dump by level, items count, item size and total size(see `$connector->getDumper()`).
- Dump objects class name.
- Smart dump of callbacks and Closure.
- Detect dump call source &amp; trace(call `$connector->getDebugDispatcher()->detectTraceAndSource = true`).

### How to call

[](#how-to-call)

**Longest** native debug method call:

```
PhpConsole\Connector::getInstance()->getDebugDispatcher()->dispatchDebug($var, 'some.tags');

```

**Shorter** call debug from Handler:

```
PhpConsole\Handler::getInstance()->debug($var, 'some.tags');

```

**Shortest** call debug using global `PC` class

```
PhpConsole\Helper::register(); // it will register global PC class
// ...
PC::debug($var, 'tag');
PC::tag($var);

```

**Custom** call debug by user defined function

```
function d($var, $tags = null) {
	PhpConsole\Connector::getInstance()->getDebugDispatcher()->dispatchDebug($var, $tags, 1);
}
d($var, 'some.tags');

```

### Tags

[](#tags)

- Debug tags argument is optional.
- Tags is a string with tags separated by dot(e.g. "low.db").
- Tags can be used to identify what exactly var was dumped.
- You can configure client to ignore displaying some tags.

Remote PHP code execution
-------------------------

[](#remote-php-code-execution)

[![ScreenShot](https://camo.githubusercontent.com/9425bb77a8acba362243da54f5d39c1f69da3e8db6e7132fcef07c57fff3009d/687474703a2f2f636f6e736c652e636f6d2f7265732f73637265656e73686f742f6576616c5f7465726d696e616c5f3432302e706e67)](http://consle.com/instance/examples/#eval_terminal)

PHP Console provide a way to execute PHP code on your server remotely, from Google Chrome extension terminal.

- Remote PHP code execution allowed only in password protected mode
- Every eval request is signed with unique SHA-256 token
- Result contains: `output`, `return` and `time` data
- Errors &amp; exception occurred during PHP code execution will be handled

### Configuration

[](#configuration)

```
$connector = PhpConsole\Connector::getInstance();
$connector->setPassword($password);

// Configure eval provider
$evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
$evalProvider->addSharedVar('post', $_POST); // so "return $post" code will return $_POST
$evalProvider->setOpenBaseDirs(array(__DIR__)); // see http://php.net/open-basedir

$connector->startEvalRequestsListener(); // must be called in the end of all configurations

```

PSR-3 logger implementation
---------------------------

[](#psr-3-logger-implementation)

There is PHP Console implementation of [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) interface. to integrate PHP Console with PSR-3 compitable loggers(e.g. [Monolog](https://github.com/Seldaek/monolog)). See [PhpConsole\\PsrLogger](src/PhpConsole/PsrLogger.php).

Jump to file
------------

[](#jump-to-file)

Read [this article](https://github.com/barbushin/php-console/wiki/Jump-to-file) if you want to configure PHP Console extension to open errors/exceptions source file:line right in your IDE, just by click on the button in Notification popup.

Easy migrate from PhpConsole `v1.x` to `v3.x`
---------------------------------------------

[](#easy-migrate-from-phpconsole-v1x-to-v3x)

If you have used PhpConsole `v1.x` and want to migrate to `v3.x` without any code changes, so just use [PhpConsole\\OldVersionAdapter](src/PhpConsole/OldVersionAdapter.php):

```
PhpConsole\OldVersionAdapter::register(); // register PhpConsole v1.x class emulator

// Call old PhpConsole v1 methods as is
PhpConsole::start(true, true, $_SERVER['DOCUMENT_ROOT']);
PhpConsole::debug('Debug using old method PhpConsole::debug()', 'some,tags');
debug('Debug using old function debug()', 'some,tags');
echo $undefinedVar;
PhpConsole::getInstance()->handleException(new Exception('test'));

// Call new PhpConsole methods, if you want :)
PhpConsole\Connector::getInstance()->setServerEncoding('cp1251');
PhpConsole\Helper::register();
PC::debug('Debug using new methods');

```

But, anyway, if you can't migrate to new version of PHP Console because of using PHP &lt; 5.3 on your servers, then you can use old [deprecated version](https://groups.google.com/forum/?hl=ru#!forum/php-console-deprecated-version) of PHP Console.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 88.1% 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 ~185 days

Recently: every ~371 days

Total

12

Last Release

2480d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49ee9003109866ee01a052ac1c956a4302217912349bac7c43c297647b3694f3?d=identicon)[haohetao](/maintainers/haohetao)

---

Top Contributors

[![barbushin](https://avatars.githubusercontent.com/u/683352?v=4)](https://github.com/barbushin "barbushin (111 commits)")[![nhorvath](https://avatars.githubusercontent.com/u/165084?v=4)](https://github.com/nhorvath "nhorvath (5 commits)")[![haohetao](https://avatars.githubusercontent.com/u/4592571?v=4)](https://github.com/haohetao "haohetao (3 commits)")[![TimSchmittmann](https://avatars.githubusercontent.com/u/9949670?v=4)](https://github.com/TimSchmittmann "TimSchmittmann (1 commits)")[![tm1000](https://avatars.githubusercontent.com/u/564256?v=4)](https://github.com/tm1000 "tm1000 (1 commits)")[![unfulvio](https://avatars.githubusercontent.com/u/1227930?v=4)](https://github.com/unfulvio "unfulvio (1 commits)")[![0xflotus](https://avatars.githubusercontent.com/u/26602940?v=4)](https://github.com/0xflotus "0xflotus (1 commits)")[![xelan](https://avatars.githubusercontent.com/u/5080535?v=4)](https://github.com/xelan "xelan (1 commits)")[![Chi-teck](https://avatars.githubusercontent.com/u/673139?v=4)](https://github.com/Chi-teck "Chi-teck (1 commits)")[![rubensainiuc](https://avatars.githubusercontent.com/u/3584354?v=4)](https://github.com/rubensainiuc "rubensainiuc (1 commits)")

---

Tags

phpdebugerrorserror-handlerchromegoogle chrome

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[php-console/php-console

PHP library for Google Chrome extension "PHP Console".

1.3k2.9M41](/packages/php-console-php-console)[php-console/laravel-service-provider

Laravel service provider to handle PHP errors, dump variables, execute PHP code remotely in Google Chrome

7361.2k1](/packages/php-console-laravel-service-provider)[jbzoo/jbdump

Script for debug and dump PHP variables and other stuff. This tool is a nice replacement for print\_r() and var\_dump() functions.

211.1M3](/packages/jbzoo-jbdump)[h4cc/phpqatools

A meta composer package for PHP QA Tools.

6418.6k1](/packages/h4cc-phpqatools)[kuria/error

Makes handling and debugging PHP errors suck less

1920.0k2](/packages/kuria-error)

PHPackages © 2026

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