It does not generate or send HTML and is not intended to be visited
in a browser.
It generates either plain text or JSON.
The PHP accepts messages from the JavaScript which are sent as request
data, and stores them in a file. It responds with just a plain text
OK or error message.
It accepts polls and responds with an error or a JSON document
reporting any requested messages. (This could be zero messages.)
The send method uses a newer feature called a “promise”.
A promise is an improved way of managing callbacks. It
essentially represents some task that is in queue (pending),
competed (fulfilled) or failed (rejected). (Failure essentially
means it threw an exception.)
The then method runs a callback with the result
if and when the task succeeds.
The catch method (not statement) runs a callback if and
when the task fails.