Skip to content

Commit

Permalink
added tools & examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 13, 2013
1 parent f22c788 commit 539c44e
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor
/composer.lock
/tools/create-phar/tracy.phar
26 changes: 26 additions & 0 deletions tools/create-phar/create-phar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

// creates tracy.phar
if (!class_exists('Phar') || ini_get('phar.readonly')) {
echo "Enable Phar extension and set directive 'phar.readonly=off'";
die(1);
}

unlink('tracy.phar');

$p = new Phar('tracy.phar');
$p->setStub('<?php
require "src/tracy.php";
__halt_compiler();
');

$p->startBuffering();
foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/../../src')) as $file) {
echo "adding: {$iterator->getSubPathname()}\n";
$p[$iterator->getSubPathname()] = php_strip_whitespace($file);
}

$p->stopBuffering();
$p->compressFiles(Phar::GZ);

echo 'OK';
45 changes: 45 additions & 0 deletions tools/examples/Firebug-dump.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php ob_start(); // needed by FireLogger ?>

<!DOCTYPE html><link rel="stylesheet" href="assets/style.css">

<h1>FireLogger demo</h1>

<p>Requires Firefox, Firebug and <a href="http://firelogger.binaryage.com">FireLogger</a>.</p>

<?php

require __DIR__ . '/../../src/tracy.php';

use Tracy\Debugger;


$arr = array(10, 20, array('key1' => 'val1', 'key2' => TRUE));

// will show in FireLogger tab in Firebug
Debugger::fireLog('Hello World');
Debugger::fireLog($arr);


function first($arg1, $arg2)
{
second(TRUE, FALSE);
}



function second($arg1, $arg2)
{
third(array(1, 2, 3));
}


function third($arg1)
{
throw new Exception('The my exception', 123);
}

try {
first(10, 'any string');
} catch (Exception $e) {
Debugger::fireLog($e);
}
Binary file added tools/examples/assets/arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions tools/examples/assets/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
body {
font: 15px/1.5 Tahoma, Verdana, Myriad Web, Syntax, sans-serif;
color: #333;
background: #fff url('dibi-powered.gif') no-repeat 99% 1em;
margin: 1.6em;
padding: 0;
}

h1 {
font-size: 210%;
font-weight: normal;
color: #036;
}

pre.tracy-dump {
border: 1px solid silver;
padding: 1em;
margin: 1em 0;
}

a {
color: #000080;
}
24 changes: 24 additions & 0 deletions tools/examples/barDump.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css">

<style> html { background: url(assets/arrow.png) no-repeat bottom right; height: 100%; } </style>

<h1>Tracy Debug Bar demo</h1>

<p>You can dump variables to bar in rightmost bottom egde.</p>

<?php

require __DIR__ . '/../../src/tracy.php';

use Tracy\Debugger;

Debugger::enable();

$arr = array(10, 20.2, TRUE, NULL, 'hello', (object) NULL, array());


Debugger::barDump(get_defined_vars());

Debugger::barDump($arr, 'The Array');

Debugger::barDump('<a href="#">test</a>', 'String');
39 changes: 39 additions & 0 deletions tools/examples/dump.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css">

<h1>Tracy Dumper demo</h1>

<?php

require __DIR__ . '/../../src/tracy.php';

use Tracy\Debugger;


Debugger::enable();

class Test
{
public $x = array(10, NULL);

private $y = 'hello';

protected $z = 30;
}

$arr = array(10, 20.2, TRUE, NULL, 'hello', (object) NULL, array(), fopen(__FILE__, 'r'));

$obj = new Test;


dump('<a href="#">test</a>');

dump($arr);

dump($obj);


echo "<h2>With location</h2>\n";

Debugger::$showLocation = TRUE;

dump($arr);
33 changes: 33 additions & 0 deletions tools/examples/exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css">

<h1>Tracy Exception demo</h1>

<?php

require __DIR__ . '/../../src/tracy.php';

use Tracy\Debugger;

Debugger::enable();


function first($arg1, $arg2)
{
second(TRUE, FALSE);
}



function second($arg1, $arg2)
{
third(array(1, 2, 3));
}


function third($arg1)
{
throw new Exception('The my exception', 123);
}


first(10, 'any string');
35 changes: 35 additions & 0 deletions tools/examples/fatal-error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css">

<h1>Tracy Fatal Error demo</h1>

<?php

require __DIR__ . '/../../src/tracy.php';

use Tracy\Debugger;


Debugger::enable();



function first($arg1, $arg2)
{
second(TRUE, FALSE);
}



function second($arg1, $arg2)
{
third(array(1, 2, 3));
}


function third($arg1)
{
missing_funcion();
}


first(10, 'any string');
8 changes: 8 additions & 0 deletions tools/open-in-editor/install.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
:: This Windows batch file sets open-editor.js as handler for editor:// protocol

if defined PROCESSOR_ARCHITEW6432 (set reg="%systemroot%\sysnative\reg.exe") else (set reg=reg)

%reg% ADD HKCR\editor /ve /d "URL:editor Protocol" /f
%reg% ADD HKCR\editor /v "URL Protocol" /d "" /f
%reg% ADD HKCR\editor\shell\open\command /ve /d "wscript \"%~dp0open-editor.js\" \"%%1\"" /f
44 changes: 44 additions & 0 deletions tools/open-in-editor/open-editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// NetBeans
// var editor = '"C:\\Program Files\\NetBeans 6.9.1\\bin\\netbeans.exe" "%file%:%line%" --console suppress';

// Nusphere PHPEd
// var editor = '"C:\\Program Files\\NuSphere\\PhpED\\phped.exe" "%file%" --line=%line%';

// SciTE
// var editor = '"C:\\Program Files\\SciTE\\scite.exe" "-open:%file%" -goto:%line%';

// EmEditor
// var editor = '"C:\\Program Files\\EmEditor\\EmEditor.exe" "%file%" /l %line%';

// PSPad Editor
// var editor = '"C:\\Program Files\\PSPad editor\\PSPad.exe" -%line% "%file%"';

// gVim
// var editor = '"C:\\Program Files\\Vim\\vim73\\gvim.exe" "%file%" +%line%';

// Sublime Text 2
// var editor = '"C:\\Program Files\\Sublime Text 2\\sublime_text.exe" "%file%:%line%"';

var mappings = {
// '/remotepath': '/localpath'
};

if (typeof editor === 'undefined') {
WScript.Echo('Create variable "editor" in ' + WScript.ScriptFullName);
WScript.Quit();
}

var url = WScript.Arguments(0);
var match = /^editor:\/\/open\/\?file=(.+)&line=(\d+)/.exec(url);
if (match) {
var file = decodeURIComponent(match[1]).replace(/\+/g, ' ');
for (var id in mappings) {
if (file.indexOf(id) === 0) {
file = mappings[id] + file.substr(id.length);
break;
}
}
var command = editor.replace(/%line%/g, match[2]).replace(/%file%/g, file);
var shell = new ActiveXObject("WScript.Shell");
shell.Exec(command.replace(/\\/g, '\\\\'));
}

0 comments on commit 539c44e

Please sign in to comment.