» Installation instructions
With PEAR
From commande line
> pear install PHP_Debug
Copy the css/js/images folders of /your_pear_root/data/PHP_Debug
in your project directory
Then you will have to modify the path of these resources in the
debug options (check PHP_Debug_HTML_Div_test.php)
Standalone
Dezip the package, the 3 tests should work without any modifications,
except for the view source fonctionnality where you will have to modify
the options in 'PHP_Debug_ShowSource.php'(CSS_ROOT, ALLOWED_PATH, PEAR_ROOT)
PS: If PEAR is already in the path you can comment the "set_include_path" line
When you create your PHP_Debug object, don't forget to setup the path
ot the view source path, default is "./PHP_Debug_ShowSource.php"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<?php
static private Array = array(
'DEBUG_restrict_access' => false,
'DEBUG_allow_url_access' => true,
'DEBUG_url_key' => 'pdw',
'DEBUG_url_pass' => 'pdw',
'DEBUG_enable_watch' => false,
'DEBUG_replace_errorhandler' => true,
'DEBUG_lang' => 'FR',
'HTML_TABLE_view_source_script_name' => 'PHP_Debug_ShowSource.php',
'HTML_TABLE_view_source_excluded_template' => array('')
);
?> |
Hello World ! (click here)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
| <?php
@package @filesource
echo '<?xml version="1.0" encoding="UTF-8"?>';
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>PEAR::PHP_Debug, Hello World !</title>
<?php
$options = array(
'HTML_DIV_images_path' => 'images',
'HTML_DIV_css_path' => 'css',
'HTML_DIV_js_path' => 'js',
);
include_once('PHP/Debug.php');
$Dbg = new PHP_Debug($options);
?>
<script type="text/javascript" src="<?php echo $options['HTML_DIV_js_path']; ?>/html_div.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo $options['HTML_DIV_css_path']; ?>/html_div.css" />
</head>
<body>
<div>
<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
</div>
<?php
echo '<div><h1>PEAR::PHP_Debug, Hello World !</h1></div>';
$Dbg->add('DEBUG INFO');
$Dbg->display();
?>
</body>
</html> |
Full example (click here)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
| <?php
@package @author @since @filesource
error_reporting(E_ALL);
$options = array(
'render_type' => 'HTML',
'render_mode' => 'Div',
'restrict_access' => false,
'allow_url_access' => true,
'url_key' => 'key',
'url_pass' => 'nounou',
'enable_watch' => false,
'replace_errorhandler' => true,
'lang' => 'FR',
'enable_w3c_validator' => isset($_GET['enable_w3c_validator']) ? $_GET['enable_w3c_validator'] : false,
'HTML_DIV_view_source_script_name' => 'PHP_Debug_ShowSource.php',
'HTML_DIV_remove_templates_pattern' => true,
'HTML_DIV_templates_pattern' =>
array(
'/home/phpdebug/www/' => '/projectroot/'
),
'HTML_DIV_images_path' => 'images',
'HTML_DIV_css_path' => 'css',
'HTML_DIV_js_path' => 'js',
);
$allowedip = array(
'127.0.0.1'
);
require_once 'PHP/Debug.php';
define('ADD_PEAR_ROOT', '/home/phpdebug/www/libs/PEAR');
set_include_path(ADD_PEAR_ROOT . PATH_SEPARATOR. get_include_path());
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Pear::PHP_Debug</title>
<script type="text/javascript" src="'. $options['HTML_DIV_js_path'] .'/html_div.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="'. $options['HTML_DIV_css_path'] .'/html_div.css" />
';
?>
</head>
<body>
<h1>PEAR::PHP_Debug -------------------------></h1>
<p>
<a href="PHP_Debug_HTML_Div_test.php">» HTML_DIV Renderer</a><br/>
<a href="PHP_Debug_HTML_Div_test.php?enable_w3c_validator=1">» HTML_DIV Renderer with W3C output validation</a><br/>
<a href="PHP_Debug_HTML_Table_test.php">» HTML_Table Renderer</a><br/>
<a href="PHP_Debug_test.php">» Test min</a><br/>
<a href="PHP_Debug_Sources.php">» Show sources</a><br/>
</p>
<?php
$watchedVariable = 1;
$_SESSION['Kikoo'] = "One session variable defined";
$Dbg = new PHP_Debug($options);
$renderer = 'HTML_Div';
$intro = 'This is the <b>'. $renderer.'_Renderer</b>, client IP is '.
$_SERVER['REMOTE_ADDR'];
$Dbg->add($intro);
$debug_line = $Dbg->add('Manual performance monitoring');
$debug_line->setStartTime();
for ($i = 0; $i < 20000; $i++) {
$j = 0;
}
$debug_line->setEndTime();
$Dbg->addSetting($renderer, 'app_renderer_mode');
$Dbg->addSettings($options, 'app_settings');
$foo = 555;
$Dbg->dump($foo, 'Foo');
$foo2 = 37.2;
$Dbg->dump($foo2, 'Foo2');
$Dbg->dump($options, 'Options');
$testObject = new PHP_DebugLine('info info info inside DebugLine object');
$testObject = $Dbg->dump($testObject);
$action = 'view_test_action';
$Dbg->setAction($action);
function a()
{
global $Dbg, $watchedVariable;
$Dbg->addDebug('call from a() fonction');
$Dbg->stopTimer();
$watchedVariable = 501;
b();
}
function b()
{
global $Dbg, $watchedVariable;
$Dbg->add('call from b() fonction');
$watchedVariable = 502;
}
a();
$Dbg->addDebugFirst('call after b() and a() but adding in 1st');
$watchedVariable = 555;
$watchedVariable = 'converting from INT to STR';
$debug_line2 = $Dbg->add('PERF TEST : 10000 iteration');
$y = 0;
for ($index = 0; $index < 10000; $index++) {
$y = $y + $index;
}
$Dbg->stopTimer();
$Dbg->dump($debug_line2);
$Dbg->queryRel('Connecting to DATABASE [<b>phpdebug</b>] dns: root:user@mysql');
$Dbg->stopTimer();
$Dbg->query('SELECT * FROM PHP_DEBUG_USERS');
$y = 0;
for ($index = 0; $index < 10000; $index++) {
$y = $y + $index;
}
$Dbg->stopTimer();
echo $notset;
fopen('not existing!', 'r');
trigger_error('This is a custom application error !!', E_USER_ERROR);
$Dbg->error('Bad status of var x in application PHP_Debug');
$Dbg->display();
?>
</body>
</html> |
|