Skip to content

Instantly share code, notes, and snippets.

@pasamio
Created January 11, 2014 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pasamio/8365784 to your computer and use it in GitHub Desktop.
Save pasamio/8365784 to your computer and use it in GitHub Desktop.
Snippet to output usable debugging to an external file in situations where the template may not play nice with debug or when the debug output may be a couple of MB larger. Also useful for comparing various page loads, AJAX requests and a few other things.
<?php
$header[] = '<html>';
$header[] = '<head>';
$header[] = '<script src="https://code.jquery.com/jquery.js"></script>';
$header[] = '<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>';
$header[] = '<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">';
$header[] = '</head>';
$header[] = '<body style="background-color: lightgrey">';
$footer[] = '</body>';
$footer[] = '</html>';
$filename = '/tmp/joomla_debug_' . microtime(1) . '.html';
file_put_contents($filename, implode('', array_merge($header, $html, $footer)));
$html[] = '<p>Wrote out ' . $filename . '</p>';
echo str_replace('</body>', implode('', $html) . '</body>', $contents);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment