1. Go to this page and download the library: Download michel/vardumper 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/ */
dump($request, $user, $token);
// → prints each one, in order, script continues
$result = computePrice($cart);
dd($result);
// → dumps $result, then exit(1). Code below never runs.
function processOrder($order) {
btrace(); // → shows the last 5 calls that led here
// ...
}
btrace(3); // show only the last 3 calls
btrace(1); // show only the direct caller
$price = computePrice($cart);
dd_bt($price);
// → prints the call stack
// → dumps $price
// → exit(1)
dd_bt($price, backtraceLimit: 3);
$response = buildApiResponse($data);
console_log($response);
// → page stays clean
// → open DevTools (F12) → Console tab
// → you see: [VarDumper] → controller.php:42
// "Array\n(\n [status] => ok ...\n)"
console_log($request, $user, $token);
// → three separate console.log() blocks, each labelled with its file:line
use Michel\Debug\VarDumper;
use Michel\Debug\Output\OutputInterface;
class LogOutput implements OutputInterface
{
public function print($value): void
{
// send to a log file, a Slack webhook, anywhere
file_put_contents('/tmp/debug.log', print_r($value, true) . PHP_EOL, FILE_APPEND);
}
}
$dumper = new VarDumper(new LogOutput());
$dumper->dump($myVariable);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.