1. Go to this page and download the library: Download chus/php-execution-tracker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chus / php-execution-tracker example snippets
use ExecutionTracker/Tracker;
// Start tracking the execution and get the trace object
$trace = Tracker::track("Count the cats in the array");
$animals = ['🐵', '🐱', '🐶', '🐷', '🐱', '🐴', '🐱', '🐸', '🐰'];
$cats = 0;
foreach ($animals as $key => $animal) {
if($animal === '🐱') {
$cats++;
$trace->log("Cat found! We have $cats cats so far");
}
}
// End the trace and set the result
$trace->end("$cats cats found in the array");
// Print the result as JSON
echo $trace->result()->asJson();
// Result as an array
$array = $trace->result()->asArray();
// Result as a JSON string
$json = $trace->result()->asJson();
// Result as HTML
$html = $trace->result()->asHtml();
// Hiding a trace after ending it
$trace->end("Something done!");
$trace->hide();
// Alternatively, you can hide the trace directly
$trace->end("Something done!")->hide();
// Or you can pass a boolean to the end method to hide the trace
$trace->end("Something done!", true);