2
0

helpers.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. if (!function_exists('btrace')) {
  3. /**
  4. * Dump backtrace
  5. * @param int $backtraceLimit
  6. * @return void
  7. */
  8. function btrace(int $backtraceLimit = 5)
  9. {
  10. $backtraceDumper = new \Michel\Debug\BacktraceDumper();
  11. $backtraceDumper->dump($backtraceLimit);
  12. }
  13. }
  14. if (!function_exists('dd_bt')) {
  15. /**
  16. * Dump with debug trace: Dumps data and exits the script.
  17. *
  18. * @param mixed $data The data to dump.
  19. */
  20. function dd_bt($data, int $backtraceLimit = 5)
  21. {
  22. btrace($backtraceLimit);
  23. dd($data);
  24. }
  25. }
  26. if (!function_exists('dd')) {
  27. /**
  28. * Dump and die: Dumps data and exits the script.
  29. *
  30. * @param mixed ...$data The data to dump.
  31. */
  32. function dd(...$data)
  33. {
  34. dump(...$data);
  35. exit(1);
  36. }
  37. }
  38. if (!function_exists('dump')) {
  39. /**
  40. * Dump data to the output.
  41. *
  42. * @param mixed ...$data The data to dump.
  43. */
  44. function dump(...$data)
  45. {
  46. $varDumper = new \Michel\Debug\VarDumper();
  47. $varDumper->dump(...$data);
  48. }
  49. }
  50. if (!function_exists('console_log')) {
  51. /**
  52. * Log data to the javascript console.
  53. *
  54. * @param mixed ...$data The data to log.
  55. */
  56. function console_log(...$data)
  57. {
  58. $varDumper = new \Michel\Debug\VarDumper(new \Michel\Debug\Output\VarDumperOutput\ConsoleLogOutput());
  59. $varDumper->dump(...$data);
  60. }
  61. }