sFire PHP Framework

Debugger

sFire\Debugging\Debug lets you dump variables and messure PHP execution time. This can be handy if you want to debug how long a script, query or a part of a script runs.

In this section we will handle:

  • Dumping variables
  • Messure execution time

Dumping variables

To know the contents of a variable, you may call the dump method. This method will take any argument and encloses the variable in "<pre>" tags for better overview when showing in a browser.

Debug :: dump(['example' => true];

//Outputs:
<pre>Array
(
    [example] => 1
)
</pre>

You can also export variables using the second parameter. This parameter is a boolean which is Boolean false by default.

$dump = Debug :: dump(['example' => true], true);

Messure execution time

To messure the PHP execution time in seconds, you can use the time method. This method accepts a optional String parameter as key. By calling this method with a key, you are adding times on a stack. To show the elapsed time, you should call the method without the key parameter.

Example
Debug :: time('start');
sleep(1); //Wait for 1 second

Debug :: time('query');
sleep(3); //Wait for 3 seconds

print_r(Debug :: time());

//Output:
Array
(
    [start - query] => 1.0001
    [query - end] => 3.0002
)