Move PHP functions to a library