initial (untested) version of php gateway