Skip to content

Commit 539c44e

Browse files
committed
added tools & examples
1 parent f22c788 commit 539c44e

File tree

11 files changed

+278
-0
lines changed

11 files changed

+278
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/vendor
22
/composer.lock
3+
/tools/create-phar/tracy.phar

tools/create-phar/create-phar.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
// creates tracy.phar
4+
if (!class_exists('Phar') || ini_get('phar.readonly')) {
5+
echo "Enable Phar extension and set directive 'phar.readonly=off'";
6+
die(1);
7+
}
8+
9+
unlink('tracy.phar');
10+
11+
$p = new Phar('tracy.phar');
12+
$p->setStub('<?php
13+
require "src/tracy.php";
14+
__halt_compiler();
15+
');
16+
17+
$p->startBuffering();
18+
foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/../../src')) as $file) {
19+
echo "adding: {$iterator->getSubPathname()}\n";
20+
$p[$iterator->getSubPathname()] = php_strip_whitespace($file);
21+
}
22+
23+
$p->stopBuffering();
24+
$p->compressFiles(Phar::GZ);
25+
26+
echo 'OK';

tools/examples/Firebug-dump.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php ob_start(); // needed by FireLogger ?>
2+
3+
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css">
4+
5+
<h1>FireLogger demo</h1>
6+
7+
<p>Requires Firefox, Firebug and <a href="http://firelogger.binaryage.com">FireLogger</a>.</p>
8+
9+
<?php
10+
11+
require __DIR__ . '/../../src/tracy.php';
12+
13+
use Tracy\Debugger;
14+
15+
16+
$arr = array(10, 20, array('key1' => 'val1', 'key2' => TRUE));
17+
18+
// will show in FireLogger tab in Firebug
19+
Debugger::fireLog('Hello World');
20+
Debugger::fireLog($arr);
21+
22+
23+
function first($arg1, $arg2)
24+
{
25+
second(TRUE, FALSE);
26+
}
27+
28+
29+
30+
function second($arg1, $arg2)
31+
{
32+
third(array(1, 2, 3));
33+
}
34+
35+
36+
function third($arg1)
37+
{
38+
throw new Exception('The my exception', 123);
39+
}
40+
41+
try {
42+
first(10, 'any string');
43+
} catch (Exception $e) {
44+
Debugger::fireLog($e);
45+
}

tools/examples/assets/arrow.png

1.12 KB
Loading

tools/examples/assets/style.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
body {
2+
font: 15px/1.5 Tahoma, Verdana, Myriad Web, Syntax, sans-serif;
3+
color: #333;
4+
background: #fff url('dibi-powered.gif') no-repeat 99% 1em;
5+
margin: 1.6em;
6+
padding: 0;
7+
}
8+
9+
h1 {
10+
font-size: 210%;
11+
font-weight: normal;
12+
color: #036;
13+
}
14+
15+
pre.tracy-dump {
16+
border: 1px solid silver;
17+
padding: 1em;
18+
margin: 1em 0;
19+
}
20+
21+
a {
22+
color: #000080;
23+
}

tools/examples/barDump.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css">
2+
3+
<style> html { background: url(assets/arrow.png) no-repeat bottom right; height: 100%; } </style>
4+
5+
<h1>Tracy Debug Bar demo</h1>
6+
7+
<p>You can dump variables to bar in rightmost bottom egde.</p>
8+
9+
<?php
10+
11+
require __DIR__ . '/../../src/tracy.php';
12+
13+
use Tracy\Debugger;
14+
15+
Debugger::enable();
16+
17+
$arr = array(10, 20.2, TRUE, NULL, 'hello', (object) NULL, array());
18+
19+
20+
Debugger::barDump(get_defined_vars());
21+
22+
Debugger::barDump($arr, 'The Array');
23+
24+
Debugger::barDump('<a href="#">test</a>', 'String');

tools/examples/dump.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css">
2+
3+
<h1>Tracy Dumper demo</h1>
4+
5+
<?php
6+
7+
require __DIR__ . '/../../src/tracy.php';
8+
9+
use Tracy\Debugger;
10+
11+
12+
Debugger::enable();
13+
14+
class Test
15+
{
16+
public $x = array(10, NULL);
17+
18+
private $y = 'hello';
19+
20+
protected $z = 30;
21+
}
22+
23+
$arr = array(10, 20.2, TRUE, NULL, 'hello', (object) NULL, array(), fopen(__FILE__, 'r'));
24+
25+
$obj = new Test;
26+
27+
28+
dump('<a href="#">test</a>');
29+
30+
dump($arr);
31+
32+
dump($obj);
33+
34+
35+
echo "<h2>With location</h2>\n";
36+
37+
Debugger::$showLocation = TRUE;
38+
39+
dump($arr);

tools/examples/exception.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css">
2+
3+
<h1>Tracy Exception demo</h1>
4+
5+
<?php
6+
7+
require __DIR__ . '/../../src/tracy.php';
8+
9+
use Tracy\Debugger;
10+
11+
Debugger::enable();
12+
13+
14+
function first($arg1, $arg2)
15+
{
16+
second(TRUE, FALSE);
17+
}
18+
19+
20+
21+
function second($arg1, $arg2)
22+
{
23+
third(array(1, 2, 3));
24+
}
25+
26+
27+
function third($arg1)
28+
{
29+
throw new Exception('The my exception', 123);
30+
}
31+
32+
33+
first(10, 'any string');

tools/examples/fatal-error.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css">
2+
3+
<h1>Tracy Fatal Error demo</h1>
4+
5+
<?php
6+
7+
require __DIR__ . '/../../src/tracy.php';
8+
9+
use Tracy\Debugger;
10+
11+
12+
Debugger::enable();
13+
14+
15+
16+
function first($arg1, $arg2)
17+
{
18+
second(TRUE, FALSE);
19+
}
20+
21+
22+
23+
function second($arg1, $arg2)
24+
{
25+
third(array(1, 2, 3));
26+
}
27+
28+
29+
function third($arg1)
30+
{
31+
missing_funcion();
32+
}
33+
34+
35+
first(10, 'any string');

tools/open-in-editor/install.cmd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@echo off
2+
:: This Windows batch file sets open-editor.js as handler for editor:// protocol
3+
4+
if defined PROCESSOR_ARCHITEW6432 (set reg="%systemroot%\sysnative\reg.exe") else (set reg=reg)
5+
6+
%reg% ADD HKCR\editor /ve /d "URL:editor Protocol" /f
7+
%reg% ADD HKCR\editor /v "URL Protocol" /d "" /f
8+
%reg% ADD HKCR\editor\shell\open\command /ve /d "wscript \"%~dp0open-editor.js\" \"%%1\"" /f

0 commit comments

Comments
 (0)