Converting backend to PHP