-
Declaring Static Methods in PHP
10 December 2010
Read moreI was confused recently to realise that I had accidentally called a static method in PHP dynamically from another part of my code; I expected PHP to output warnings when this is done. On closer inspection I discovered that:
Static functions can be called dynamically
Dynamic functions generate an E_STRICT error if called statically
This made a lot more sense when I thought about it a bit more and wrote some toy code:
-
Retrieving Data from Google Analytics API using PHP
09 December 2010
Read moreRecently I started playing with the google analytics API, looking at ways to bring analytics onto dashboards and generate simple reports from the data in there. Very shortly after I started to look at the API, I had working data retrieval, so I thought I'd share my experiences (and code!).
-
PHPUnconference Comes to Manchester
30 November 2010
Read moreI'm very excited to hear that the PHPUnConference Europe (@phpuceu on twitter) is coming to Manchester on February 19th and 20th! So excited, in fact, that I've rushed out and bought my ticket (for a whole £40, that's a good investment in my opinion). The event brings together the PHP …
-
3 Ways to Access a Namespaced PHP Class
29 November 2010
Read moreAfter what felt like years of debate over the notation to use for PHP's namespaces, it seems like the feature itself has had relatively little use or attention since it was actually implemented in PHP 5.3. We're all used to working without it but using it does make code neater.
Take this example (in a file called namespaced-class.php)
-
Keynoting at PHPBenelux
25 November 2010
Read moreHave you got your tickets for PHPBenelux yet? If not then I hope you will do so because I would love to see you there!
I'll be delivering a keynote at the PHPBenelux Conference in Antwerp in January alongside my good friend Ivo Jansch. Between us we've got plenty of …
-
Google Analytics Accounts API
23 November 2010
Read moreI'm working with Google Analytics at the moment, to pull information about web traffic from analytics into another system. Google have excellent APIs and that makes this job much easier. I'm using pecl_oauth to authenticate users against their google accounts (see my post about using OAuth from PHP), but even after I have a valid google user, working out which analytics accounts they have access to and how to refer to them is a puzzle in itself, so I thought I'd share what I learned.These examples use pecl_http, since I have control of my platform and I find it easy to work with. I've tried to write this with explanations of the overall process in between the code snippets so hopefully this makes the process clear whether or not you will use exactly the same implementation.
-
Fetching Namespaced XML Elements With SimpleXML
03 November 2010
Read moreRecently I was working with some google APIs and needed to retrieve some namespaced elements from the result set. This confused me more than I expected it to so here's my code for the next time I need it (and if you use it too, then great!)
I was reading from their analytics data feed API, this returns a few key fields and then multiple <entry> tags, each with namespaced children. The entry tags look something like:
-
Be My Guest for DayCamp4Developers
01 November 2010
Read moreThis weekend I'm presenting at DayCamp4Developers, a virtual event comprising a full day of workshops for developers of all disciplines to improve their soft skills and move forward in their career. I get to attend since I'm speaking, but even after I've given my slot I know I'll be online …
-
Deprecated Methods in Pecl_Http
28 October 2010
Read moreI'm a big fan of pecl_http, which I use quite often as I work so regularly with APIs and on systems where I can get it installed, it's much nicer than PHP's curl extension. Recently though I've been often seeing output which reads:
Function HttpRequest::addRawPostData() is deprecated
It isn't …
-
Best Practices in API Design: Audio and Slides
15 October 2010
Read moreEarlier in the year I gave a talk at PHP UK in London entitled "Best Practice for API Design". I really enjoyed giving this talk, since I work so much with APIs and enjoy sharing my ideas. The audio is now online so if you missed the talk, feel free …
-
PHPNW10: Teach a Man to Fish
11 October 2010
Read moreLast weekend I gave a talk at PHPNW10 in Manchester, entitled "Teach a Man to Fish". This is a keynote about teams and how to use the resources around you to create a team where individuals and the whole team continues to learn and develop. The slides are not very …
-
Authenticating with OAuth from PHP
28 September 2010
Read moreI've been looking into OAuth recently and really like what I see, so I started looking at actually starting to play with something that uses it (and isn't twitter). In the pursuit of this, I spent some time walking through the process of how to actually authenticate using OAuth, as a client. I chose Yahoo!'s service, because they have some fabulous developer documentation and have a standard OAuth implementation. Although you don't strictly need any special libraries to handle OAuth, that would be a bit like decoding XML with a regex, so I used the OAuth Package from PECL. For others (including me after I've slept), here's an outline of the process.