Rewrite PHP app as REST webservice

PHP app now returns JSON for all methods except index.