Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Last active August 29, 2015 14:15
Show Gist options
  • Save sidharrell/54c9cf75f6328f35c4b3 to your computer and use it in GitHub Desktop.
Save sidharrell/54c9cf75f6328f35c4b3 to your computer and use it in GitHub Desktop.
debug to file
if(\Drupal::service('kernel')) { // make a conditional test for debug or not
ob_start();
// insert var below
var_dump(true);
// insert var above
$data = ob_get_clean();
$fp = fopen("textfile.html", "a");
// write $data or custom string, ie "I'm here".
fwrite($fp, "true");
fclose($fp);
} else {
$fp = fopen("textfile.html", "a");
// write $data or custom string, ie "I'm here".
fwrite($fp, "false");
fclose($fp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment