Last active
August 29, 2015 13:56
-
-
Save ciarand/9168570 to your computer and use it in GitHub Desktop.
Export / import PHP request details for reproducible debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // index.php | |
// bulletproof debug mode | |
define("DEBUG_MODE", rand(1, 2) === 1); | |
if (isset($_GET["trigger"]) && DEBUG_MODE) { | |
file_put_contents("request.dat", serialize(get_defined_vars())); | |
} | |
// go through normal stuff, start the app, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // test_request.php | |
// get the request variables | |
$vars = unserialize(file_get_contents("request.dat")); | |
// setup the environment | |
foreach ($vars as $key => $val) { | |
eval("\${$key} = \$val;"); | |
} | |
// now begin debugging the request | |
require "index.php"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Having trouble debugging a particular request to your web app?
index.php
stores it asrequest.dat
).\Psy\Shell::debug(get_defined_vars());
)php test_request.php
.