Skip to content
A simply PHP script to print all the details of an HTTP request.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
views
.gitignore
LICENSE
README.md
composer.json
index.php
json.php
jsonText.php
lib.php
text.php

README.md

httpEcho.php

A small collection of PHP scripts for rendering HTTP client, request, and server details as JSON, pretty-printed JSON, plain text (Markdown really), or HTML.

Installation

  1. Expand code into folder of your choice.
  2. Use Composer to install the prerequisites (just Mustache): composer install
  3. There is no step 3 🙂

Usage

There are currently four supported output formats:

  1. HTML (default):
    • ./index.php
  2. JSON with MIME-Type application/json:
    • ./index.php?want=json
    • ./json.php
  3. Pretty-printed JSON with MIME-Type text/plain
    • ./index.php?want=jsonText
    • ./jsonText.php
  4. Plain text (Markdown formatted)
    • ./index.php?want=text
    • ./text.php

Suggested NGINX Config for Nicer URLs

The following example NGINX config illustrates a technique for removing the .php from the URLs, turning URLs of the form http://server.tld/httpEcho/text.php into URLs of the form http://server.tld/httpEcho/text. Note that this sample config supports query strings, so URLs of the following form http://server.tld/httpEcho/text?p1=val1&p2=val2 will also work.

# set up httpEcho
location /httpEcho/ {
  try_files $uri $uri/ $uri.php?$query_string;
}
You can’t perform that action at this time.