Fix a number of PHP issues

This PR isn't perfect, but it at least ensures that all PHP-based frameworks can turn on and run. The remaining errors are predominantly simple validation errors, such as returning a JSON object instead of a JSON array