Skip to content

Instantly share code, notes, and snippets.

@milo
Created August 20, 2013 07:51
Show Gist options
  • Save milo/6278342 to your computer and use it in GitHub Desktop.
Save milo/6278342 to your computer and use it in GitHub Desktop.
Handy Tracy/Nette Debugger in autoprepend file
<?php
function __nette($version = NULL) {
if ($version) {
require "/var/www/lib/nette/$version/Nette/loader.php";
} else {
require '/var/www/dev/nette/Nette/loader.php';
}
}
function __debug($mode = NULL, $logDirectory = NULL, $email = NULL) {
if (!class_exists($class = 'Nette\Diagnostics\Debugger') && !class_exists($class = 'Tracy\Debugger')) {
require '/var/www/dev/tracy/src/tracy.php';
}
$class::enable($mode, $logDirectory, $email);
$class::$strictMode = TRUE;
if (!class_exists('__DebuggerAdjuster')) {
class_alias($class, 'DBG', FALSE);
class __DebuggerAdjuster
{
private $className;
public function __construct($class)
{
$this->className = $class;
}
public function __call($member, array $args)
{
$class = $this->className;
$class::$$member = array_pop($args);
return $this;
}
}
}
return new __DebuggerAdjuster($class);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment