Restructured php api

....w'll get thr