Full PHP

Complete conversion to php