Bringing PHP library more in line with Node library

The node library and php library work in different ways but could be brought more in-line. This is the start of that - to make maintenance across both easier. Next will be the Java lib likely.