PHP OAuth Provider: Access Tokens

I’ve been working with OAuth, as a provider and consumer, and there isn’t a lot of documentation around it for PHP at the moment so I thought I’d share my experience in this series of articles. This relates to the stable OAuth 1.0a spec, however OAuth2 has already started to be adopted (and differs greatly). This article uses the pecl_oauth extension and builds on Rasmus’ OAuth Provider post. This entry follows on from the ones about the initial requirements, how to how to handle request tokens, and authenticating users.
Continue reading

Drawing Flow Diagrams with GraphViz

Recently I’ve been drawing a few different kinds of diagrams for a book I was writing, and been using graphviz to create them. Since I struggled a bit to get them going the way that I wanted them to, I am sharing them here (as much for my future self as anyone else visiting, but if they help you too then that’s excellent).
Continue reading

Comment, Don’t Tweet

This blog regularly features posts which are rather niche, incomplete or in some cases simply misleading (not intentionally, I promise!). Often I post something, and then discover there was an awful lot more to know, and find that people add all kinds of constructive suggestions, resources, and other goodness in the comments.

Continue reading

Adding Markers to a Google Chart

I seem to blog about graphs a lot at the moment, but that’s because I am seeing a lot of them, with one thing and another. I recently added some little bubbles to the line graphs produced by Bitestats (obligatory elevator pitch: one-page, simple summary report pull from your google analytics account). I think they are kind of cute:

Once I got going with them, they were actually pretty straightforward. You can actually add all kinds of markers to your google chart, complete with funky icons and customisable colours! The code I added to make these is simply:


&chem=y;s=bubble_text_small;d=bb,Max:+917,FFFFFF,660066;ds=0;dp=15|y;s=bubble_text_small;d=bbtr,Min:+185,FFFFFF,660066;ds=0;dp=20

All we have here is a simple specification of which kind of bubbles I want, the label for them and which data series (ds) and data point (dp) to attach it to. I generated the bubble tail directions sensitive to whether they were a min or max label, and which half of the graph they are in.
Continue reading

PHP Static Analysis Tool Usage

Last week I tweeted a poll with the question “Which PHP static analysis tools do you regularly use?”. These are the results:
Static Analysis Tools Poll Results (phpcs 81%, phpmd 59%, phpcpd 59%, phploc 41%, phpdpd 48%)

My interest was mostly because I’m working on a book chapter which includes some static analysis content, and there are a couple of these tools that I include in my own builds, but I don’t do much with the output of them. However I didn’t want to drop anything from the chapter if it was actually a valuable tool and I was just missing the point – pretty much all the tools got a good number of votes though, so I’ll be covering all of the above. It does look as if phploc has less of a following, however it’s one of my favourite tools so it gets a mention anyway!

Thanks to everyone who took the time to vote; I thought I’d share the results in case anyone was interested.

Shortening URLs from PHP with Bit.ly

I’ve been looking around for a really simple API that would be a nice place to get started using web services from PHP – and I realised that bit.ly actually fits the bill really well. They have straightforward api docs on google code, and it’s also a pretty simple function!

Here’s a simple example, using PHP’s curl extension, of using the bit.ly API to get a short URL, using PHP (you need an API key, but if you’re a registered bit.ly user, you can log in and then find yours at http://bitly.com/a/your_api_key).

$ch = curl_init('http://api.bitly.com/v3/shorten?login=username&apiKey=R_secret&longUrl=http%3A%2F%2Flornajane.net');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);
print_r(json_decode($result));

Continue reading

Speaking at OggCamp

I’m delighted to announce that I’ll be speaking at OggCamp this year. This is an event that I’ve attended both previous years, and one that I always seem to get a lot out of. It’s an open source, anything goes, unconference kind of event. Except that this year there is also a scheduled track of talks alongside the usual unconference content.

I love oggcamp for the sheer randomness of what I learn there. I’ve variously seen talks on home automation, mapping, operating systems, politics … the list is pretty long. This year, it’s in Surrey, on the same weekend as the final deadlines for my book so I figured I’d have to give it a miss. But when I got an invite to speak on the scheduled track, I realised this was the omen I needed, and accepted at once!

I’ll be giving a talk entitled “Open Source Your Career” – a talk which brings up an aspect of open source that we often don’t discuss; the personal rewards that an individual can gain from being involved in open source. If you thought it was all about altruism, think again. I’ll be bringing anecdotes, from my own career and others’, about how the best way to fast-track your professional growth. See you in Surrey :)

Celebrating One Year in Business

A year ago, I left my job at Ibuildings and went freelance. At the time, I didn’t really know what I wanted to do next, and I was excited about the opportunity to try out a few different things. I blogged about my new (ad)venture when I launched it, but I haven’t written much since and people keep asking me for updates – the anniversary seems like a good time to reflect.

Well, I still don’t know what I want to do next, but that seems like less of a problem these days. I’m busy but in a planned-in-advance, only wearing myself down because there was something so exciting I couldn’t say no, kind of a way. I am not a great fan of travel, and have always tried to avoid it, but in fact so many interesting things came up this year that I ended up on the road more than ever. It turns out that there is a world of difference between being sent somewhere on short notice, and planning a series of interesting professional engagements that just happen to involve being away from home a lot all at once. And if I don’t want to go: I don’t go. It’s amazing how many people will wait til next month if you ask them!

Continue reading

A Book Burndown Chart

You might have noticed that things have been a bit quiet around here lately … that’s because I’m writing a book and doing a lot of editing at the moment. I love doing both of these as part of my work, but it turns out that when you’re already writing/editing 3k words a day, it’s hard to find more words to blog with (well, and I usually blog whatever code I’m writing which isn’t a whole lot right now). I did however want to share with you the news that I’m working on a book (about PHP, for the lovely Sitepoint).

I’m completely new to book-writing and it felt like a mountain to climb. I have five chapters of around 8 thousand words each to write for the book (I have co-authors, who are also lovely), and the general advice I got was to just take it all one step at a time. This sounds a lot like the way I teach project management and time management to developers, so I used those same skills and created a burndown chart (I blogged about creating these before):

As you can see, there have been some great days, and some quieter days. The flat lines are mostly weekends or days where I was out of the office with other clients. Although I feel slightly overwhelmed (and this doesn’t show the edits that come back after I submit each chapter), the graph is at least going in the right direction!