-
-
Save tas33n/eaef23267cab762b053b1d5bcf730251 to your computer and use it in GitHub Desktop.
PHP dump/log details of HTTP requests received
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 | |
# Log string to file whilst also printing it to screen (stdout) | |
# Named tee to match the core unix command - https://en.wikipedia.org/wiki/Tee_(command), | |
# which in turn is named after the T-splitter used in plumbing. | |
function tee($message, $logFilepath) | |
{ | |
file_put_contents($logFilepath, $message, FILE_APPEND); | |
echo $message; | |
} | |
$logFilepath = "/tmp/http-request-dump.log"; | |
echo "<pre>"; | |
tee("Processing Request: ".date("d/m/Y H:i:s"), $logFilepath); | |
tee("Headers: ".print_r(apache_request_headers(), true), $logFilepath); | |
$rawPOSTData = file_get_contents("php://input"); | |
tee("\nRequest:\n".print_r($rawPOSTData, true), $logFilepath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment