Simple patterns: PHP to JavaScript

You can pass data between the client and server in a number of ways. I like to mirror data structures between my server and client, so that I have the same basic data model available in both realms. There are a few ways to do this, including: Calling an API that returns JSON (or JSONP) Calling an API that returns some UI, which can include some JSON Getting an entire page that includes your data model in JSON Sending a client data is trivial in most dynamic languages, and PHP is no different. You return a response body with the result of a json_encode and your data model. The technique works just as well in APIs as it does in standard HTML templates: ...

June 25, 2013

Five things to love about PHP

PHP is a great language. It follows a long lineage of C-based syntaxes, mirroring much of the C standard library. It performs well, is trivial to deploy, and has been stable for many years. And, it’s almost universally hated. While many people look down on PHP, it’s worth considering where it shines compared to other languages. I find that in many uses, PHP provides a great set of features and elegance. Not only is it competent, but there are places where it is truly a great little tool. ...

June 17, 2013