PHPUnconference Comes to Manchester

I’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 community from across Europe to an unconference where the speakers are the presenters, and really anything goes!

A great feature is the contributions and interests section – if there’s some content that would be particularly useful to you, or a talk you think would be a good fit, then you add it on this page. All the attendees can vote for which sessions we want to see and so we crowd-source the best lineup possible :)

If you fancy some more structured PHP training then hang around in Manchester after the event because thePHPcc are bringing their PHP Days training to Manchester on the Monday and Tuesday following the weekend event, which is pretty exciting :)

Hope to see you in Manchester, all I need to do now is work out which topics I want to see/give talks about …

3 Ways to Access a Namespaced PHP Class

After 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)

namespace Christmas\DaysOf;  

class PartridgeInAPearTree{ 
}

Now we have a few ways to access that class.

Continue reading

Keynoting at PHPBenelux

Have 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 stories to tell from our experiences in various areas of development and we’d like to share those with you! I hope you’ll come along and join us, and if you are quick you can catch the early bird prices, saving 50 euro.

On a personal note I have many great friends in this part of the world and I’m super-excited to know that I’m able to visit and see both the old friends I know well and the new friends I haven’t met yet. I attended this conference last year and it had a great atmosphere; this year the content is better again and with three tracks, I don’t know how we’ll choose which sessions to see!

Are you attending? Leave a comment and make sure to come and say hi at the conference in Belgium :)

Google Analytics Accounts API

I’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.

Analytics Accounts

Your google account can have access to one or more analytics accounts. For example when I log in I have access to accounts which hold the data for lornajane.net, phpwomen.org, joind.in and a few other things I’m involved with. Only lornajane.net actually belongs to me, the others are accounts created by someone else and which I have access to. The first challenge therefore is to work out which a user has access to – the best place to start is the reference page for the Management API, part of google’s own documentation. In a nutshell, we build up a URL like this, being increasingly specific by fleshing out the values in square brackets on subsequent calls:

https://www.google.com/analytics/feeds/datasources/ga/accounts/[accountID]/
webproperties/[webPropertyID]/profiles/[profileID]/goals

First up then, is to get a list of accounts for our authorized user – I already have a valid oauth access token to use in this example Continue reading

Fetching Namespaced XML Elements With SimpleXML

Recently 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: Continue reading

Be My Guest for DayCamp4Developers

This 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 to watch the other talks and I know I’ll learn something myself! I believe that, however good your technical skills are, being able to communicate effectively means the different between being the bearded expert in the corner who knows everything but has been in the same job 10 years, and being the high flier that soft skills and technical skills combined could make you.

I have one guest ticket for this event, and I want to make sure that it goes to someone who will make good use of it. So, if you would like to be my guest for DayCamp4Developers, this weekend 6th November, then leave me a comment and tell me why you want to attend. In a couple of days (probably Wednesday evening, UK time) I’ll close the comments and pick a winner – put your email address in the comments box (it isn’t displayed) so I can reach you and let you know.

If you don’t win, and want to join us anyway, then you can still buy tickets. Check with your local user group if they have an affiliate code and if not – use this link to buy your tickets, using my affiliate code ;)

Looking forward to “seeing” everyone on Saturday!

Posted in php

Deprecated Methods in Pecl_Http

I’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 obvious from the PHP manual page what I ought to do instead, however further inspection shows that it is recommended to use setBody() instead. This can be used in exactly the same way, and my code seems to work perfectly well with this substitution. If you have any more information about this change, leave me a comment – I’d be interested to hear it.

Best Practices in API Design: Audio and Slides

Earlier 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 to have a listen. You can also see the slides (on slideshare) and also read the series of blog posts I wrote on this topic which originally inspired the talk.

PHPNW10: Teach a Man to Fish

Last 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 detailed, but I’ll be blogging some of the items I mentioned (requests welcome, if you saw it and would like to see any of it written down then just leave me a comment!). Slides:

Authenticating with OAuth from PHP

I’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.

Continue reading