ChromePHP for MODx

ChromePHP for MODx

New way how to log things from PHP scripts in MODx. You will not need remote tools or MODx internal log system, anymore. Log things right into yours Chrome Console, even xPDO objects!

What it can do

With ChromePHP package you can easily log anything you want, from MODx right to Chrome Console. You can use chromephp from every PHP script in MODx, doesn't matter if it's snippet, controller, connector, processor, and others.

You can log whole xPDO objects by ChromePHP without any preparing transformation. ChromePHP itself's detects and recognize xPDO object and transform them to array.

Installation

Before you can start using ChromePHP you will need one more thing than installed ChromePHP package. And that is Chrome Logger that can be installed from Chrome store. After installing Chrome Logger, make sure that it is turned on (signalized by blue icon).

And now you are ready to log.

Logging things

When you have ChromePHP package installed in your MODx, yours MODx class will be extended by chromephp class. And this class grants you an access to logging methods.

  • log()
  • warn()
  • error()
  • group()
  • groupCollapsed()
  • groupEnd()

Examples

$this->modx->chromephp->log('Log example');
$this->modx->chromephp->warn('Warn example');
$this->modx->chromephp->error('Error example');

$this->modx->chromephp->group('Group');
$this->modx->chromephp->log('Log example inside a group');
$this->modx->chromephp->groupEnd();

$this->modx->chromephp->groupCollapsed('Collapsed group');
$this->modx->chromephp->error('Error example inside a collapsed group');
$this->modx->chromephp->groupEnd();

$this->modx->chromephp->log('More log', 'in one', 'call', 'can be used', 'in all methods');

$this->modx->chromephp->log($this->modx->getObject('modResource', 1));

Tips for PhpStorm

If you are using PhpStorm or any other smart IDE you can make Live Temaples for logging methods.

I made for myself these (in square brackets are template texts):

  • log [$this->modx->chromephp->log($END$);]
  • warn [$this->modx->chromephp->warn($END$);]
  • err [$this->modx->chromephp->error($END$);]
  • gr [$this->modx->chromephp->group($END$);]
  • end [$this->modx->chromephp->groupEnd();]
Post By John Peca MODX