skunkbad / debug-to-browser-tab
Dump debugging data into a browser tab
v1.0.3
2023-10-28 03:29 UTC
Requires
- php: >=7.2.5
- symfony/console: ^5.1.5
- symfony/var-dumper: ^5.1.5
This package is auto-updated.
Last update: 2024-11-28 05:41:33 UTC
README
This package allows for debugging PHP variables in a browser tab.
Through Symfony VarDumper, debugging data is written to a log file. Browsersync is set up to watch the log file, and when it does your browser tab will reload the contents of a PHP file that includes the log file.
If you don't have Gulp or Browsersync:
cd /your/project/path
npm install --global gulp-cli
npm install --global browser-sync
You need to integrate Browsersync. I use Gulp, so the following is integrated into my Gulpfile.js:
const host = 'example.com'; // Change this to your domain name
const vndr = 'vendor/src/'
const gulp = require('gulp');
const bs = require('browser-sync').create();
gulp.task('dumplog', function() {
bs.init({
files: [vndr + 'dumpLog.txt'],
proxy: host + '/' + vndr + 'dumpLog.php?vndr=' + encodeURIComponent(vndr)
});
});
Load the debugger in your PHP, right after including composer's autoloader:
<?php
require 'vendor/autoload.php';
new \Skunkbad\Debugger\DebugToBrowserTab;
start Browsersync:
cd /your/project/path
gulp dumplog
While working in PHP, use the dump function to send debugging data to the browser tab:
<?php
dump( $foo );