Speaking at PHPNW May

Next week I’m speaking at the PHPNW User Group in Manchester on Tuesday Evening, 4th May – full details of the event are on upcoming.org. The talk isn’t directly about PHP though; I’ll be giving my “Open Source Your Career” talk, discussing how contributing to the community can really help your professional rise. I’ll be giving the this talk at the TEK-X conference in Chicago a few weeks later as well, hope to see you at either one event or the other!

WordPress Plugin for Joind.In

In case anyone thinks I’ve gone joind.in crazy after already writing about its import functionality this week, I really haven’t. Its just that some months of pulling a few things together have finally bourne fruit and so I can actually write about them now they are done! The good news is that this includes a plugin for wordpress, which pulls data from the joind.in website. You can find its official page on the wordpress plugin directory here: http://wordpress.org/extend/plugins/joindin-sidebar-widget/

Plugin Features

At the moment the plugin can display one of two data sets: The hot events on joind.in; or the talks from an event on joind.in. You can change the title on the block, limit the maximum number of records returned, specify which event the talks should come from and also indicate if you’d like the order randomised. You can see the plugin in action on techPortal, where it is picking a few sessions at this year’s Dutch PHP Conference to tempt you with!

Technical Information

I hadn’t written a wordpress plugin before although I was very familiar with the joind.in API and how to work with it from PHP. The plugin was relatively easy to write, there are plenty of tutorials on the web and I didn’t need to do anything particularly clever. I looked at a twitter plugin, tweetblend, which was a similar sort of idea in that it had settings, talked over an API, and stored data, and used that when I got stuck. My plugin is much simpler but that’s OK (and probably makes it a good example for me next time I want to write one of these things!!)

The plugin creates a database table when it is activated (and drops it when deactivated) which caches the data pulled from joind.in for a few minutes. This helps avoid lots of users having to wait for the data to load and also hopefully stops the plugin from pushing too much load to the joind.in servers. Since there is no limit or pagination on the joind.in API, even though only a few records are shown the whole result is cached. This means that if you turn on the randomise then the cache is still useful! The “random” is a bit contrived in that it just picks elements out of the array that haven’t been used but it looks fine to me.

Initially I was just going to put something together and upload it to the techportal site but I was persuaded that it would be a useful thing to share – so there it is. Comments and suggestions are all welcome – and if you are using it to publicise your event, let me know!

Importing Data to Joind.In

Update! This post is now outdated – the import functionality on joind.in has been replaced with a CSV import.

As a conference organiser I work extensively with the site joind.in, which allows attendees to comment on sessions at a conference. Recently the site has also started supporting sessions with both times and tracks, making it indispensable as a way of keeping track of all the sessions during an event. The only downside is entering all the data into it!! Joind.in does have some import functionality, which I recently rebuilt to reflect the timings and track changes, however this only accepts XML at present, so there is still some preparation work to get your data ready to import.

I know I’m not the only conference organiser who will have this problem so here’s my step-by-step guide to getting talk information into joind.in, easily and quickly. For up-to-date documentation on the joind.in import process and the official data format description, see http://joind.in/about/import.

Set up Event and Tracks

Step one is to submit your event to joind.in. When it is approved by the administrators you will receive notification and it will appear publicly on the site (joind.in also supports private events, see the website for more information).

Once it is approved, make sure the timezone is set correctly by editing your event. For me this is Europe/Amsterdam, since I’m setting up data for the Dutch PHP Conference.

If you are going to include information about the different tracks, either rooms or subject tracks, you can set these up now (if not, then skip to the next section). When viewing an event, if you are logged in and have admin rights on that event, you will see an “Event Admin” box. The “Event Tracks” screen will let you add, edit and remove the tracks for your event.

Prepare Your Data

I had the talks in a spreadsheet and I found this was a good starting point. Each row is imported independently so each one needs to contain all the information about the session. My spreadsheet had the following columns:

  • Date
  • Time
  • Track (string name matching the track you set up earlier)
  • Type (either “Social Event”, “Talk”, “Keynote”, or “Workshop”)
  • Speaker
  • Session
  • Abstract

There was a lot of duplication here, for example lots of copied and pasted dates, but for each row to be evaluated separately, we need it to look like this. At this point I exported the spreadsheet to .csv format but joind.in currently only supports XML so I still had to built the format it could understand.

Generate the XML

I wrote a little script that processed my CSV file and spat out the XML that joind.in was expecting. There are a few pitfalls with this step:

  • I’m British, so my date formats assume dd/mm/yyyy
  • The import doesn’t support languages (see http://github.com/enygma/joind.in/issues#issue/91)
  • The script contains a function copy/pasted out of the joind.in codebase to handle the timezones calculation (because I already had it working once, I just stole it)
  • The first row in the spreadsheet is assumed to contain titles and is ignored
  • The script has a hardcoded timezone in it for Europe/Amsterdam

By now you can guess this use-once script is a bit of a mess but in case it is useful I am uploading it here (if nothing else, I guess I might use it again!). I considered adding support for CSV files into joind.in itself (I’m a contributor) but I was short on time – if this would be useful to you or if you have any other comments on the process then add them here and I will do my best to reply!

Resources

  • Conversion script for CSV files to Joind.in XML format (use at your own peril!) csvToXml.txt – change the file extension to .php
  • My original spreadsheet, in case an example is helpful talks.csv – this is the data for DPC 2010

OOP Articles on Think Vitamin

I’ve been working on a series of articles for Think Vitamin, the Carsonified blog, about OOP in PHP5. In fact I’m wildly excited about this, partly because I love to write and partly because its such a cool site to write for! The first two installments are now live:

  • Getting Started with OOP PHP5 – which is a very gentle overview of why OOP is such a buzz word, and shows off some very simple examples on how to begin and what the terms mean
  • Getting Started with OOP PHP5: Part 2 – a follow on post showing constructors, static properties and methods, and also looks at how PHP handles objects.

None of it is rocket science but these are important topics often skated over by writers wanting to get to the complicated bits! Hopefully these posts bridge the gap between the very dated introductory PHP content that is still lying around on the web and the tutorials about shiny new stuff that are more typically found elsewhere. The community over on Think Vitamin is great, the comments and retweets have been very constructive and I’m very excited to be involved.

Publications

I find I’m writing for a few outlets other than just my blog these days and often want to refer people to that content as well, so I’ve added a “Publications” page, linked from the left hand sidebar. This will keep up with the articles I’m posting elsewhere, interviews, and anything else along those lines, all in one place.

Speaking at PHPWM: April 6th

Next week I will be making the trip to my original home town of Birmingham to speak at the PHP West Midlands User Group, on 6th April. They are an active user group and although I haven’t managed to organise myself to attend their meetings before, I do keep meeting their members at other technical events so I know they are a good crowd and I’m looking forward to this! My talk will be “SVN in a Distributed World” – looking at the features of SVN, of the distributed source control solutions, and thinking about whether SVN is now an outdated technology or whether it is still a good choice for source control.

Hope to see you there!

PHP London Conference: In Review

I’m really late with this post, but I wanted to write about the PHP London Conference which was held in London last Friday. The event was in a great venue and had hoards of people – this was my fourth year in attendance!! They do, however, have the longest twitter tag in history #phpuk2010!

This year I had the privilege of speaking at this event, although I was concerned that I had to stay coherent and alert right through to the graveyard slot at 4:30pm (conference organisers take note: I really am much sparklier in the mornings!). I kept myself awake by attending what I affectionately refer to as the “Ibuildings track” – with 4 speakers at the event, it did feel like a bit of an invasion by myself and my colleagues. In our defence I can only say that we are a pretty big local PHP employer and, as a developer, I’m happy to be working for someone who sends all their developers to these events, and even happier to be in the company of those other excellent speakers as colleagues!

My talk was entitled “Best Practices in Web Service Design” although perhaps “Things I Wish Web Service Creators Would Consider Before Writing Unclear and Unstable Useless And Frustrating Services” would have been a better title! I talked about web services in general, a bit about HTTP and the various service types, and also gave some general tips and tricks for writing good, stable services. In a bit of a break with geeky tradition, I then talked about services as a whole package, and how to deliver and document them in a way that helps users help themselves. If you are interested the slides are here:

http://www.slideshare.net/lornajane/best-practices-in-web-service-design

The experience was overall very positive for me, I haven’t spoken at this conference before and I was very pleased to be included. My talk went quite smoothly, with my nerves nicely hidden away (I’ve had issues with this lately), and I also avoided falling over either the curtain or the piece of screen that was carefully placed to trip unwary speakers! I’d like to thank everyone who came and asked questions afterwards, and all those who saw my talk and left comments for me on my joind.in talk page – it all helps me to do better next time, thanks and I’ll see you all next year!

An iPhone App for Joind.in

Recently I’ve been doing some bits and pieces with the open sourced event feedback site joind.in, including some work on its API to facilitate development of an iphone app. As a conference attendee, speaker and organiser, I use this site a lot for the various events that I am involved with and its a great asset.

My boyfriend Kevin was thinking of developing an iphone app, mostly to find out more about the technology, and I suggested he take a look at the API for joind.in and consider building something on that. The joind.in project belongs to enygma, a.k.a. Chris Cornutt from phpdeveloper.org and he has the code available on github – so we grabbed it. The API wasn’t previously used by much so we were able to tidy it up a bit and then consume it from the iphone to suit our needs. Chris has accepted my alterations to his existing project with grace – even when I’ve totally broken the live site with them!!

The joind.in site is a classic MVC setup and the API already existed within the application. It is implemented with a separate set of controllers for the various actions supported by the API, which all inherit from a controller which handles the output formats etc for the XML and JSON responses. It isn’t the world’s best API but its perfectly sufficient for the task at hand – I intend to write some examples for using it but until then you can read this post from Derick about how he used the joind.in API to pull in comments on his talks onto his own site.

The app itself has the core functionality of joind.in that an attendee would want in his pocket at an event. The events and their details are there, along with the talks at each event. Attendees can leave comments on the various talks and socials, and these can be browsed in the app as well. To give you a little taste of the app, here are some screenshots:

img_0023 img_0024 img_0025

If you have an iphone or ipod touch and you’re attending an event any time soon, then download the app – its under “utilities” in the app store. Comments, suggestions, bug reports and feature requests are all gratefully received (no promises about fixing/implementing them but we’ll do our best!). Our app went from submission to approved in 3 days which is very fast – thanks apple!

PHP and JSON

This is a quick outline on working with JSON from PHP, which is actually pretty simple to do. This post has some examples on how to do it and what the results should look like. JSON stands for JavaScript Object Notation, and is widely used in many languages (not just JavaScript) for serialisation. It is particularly popular for use in web services.

Writing JSON From PHP

Imagine we have a multidimensional array in PHP that looks something like this:

$menu['starter'] = array( "prawn cocktail",
                          "soup of the day");
$menu['main course'] = array( "roast chicken",
                              "fish 'n' chips",
                              "macaroni cheese");
$menu['pudding'] = array( "cheesecake",
                          "treacle sponge");

echo json_encode($menu);

The output of this script looks like this:

{"starter":["prawn cocktail","soup of the day"],"main course":["roast chicken","fish 'n' chips","macaroni cheese"],"pudding":["cheesecake","treacle sponge"]}

This is pretty typical of a JSON output string – you can see the curly brackets to enclose the whole thing, then some square brackets to show the nesting levels within the key/value formats. JSON is an ideal format for many applications because it is easy to understand and debug, its quite concise, and many languages have built-in support just like PHP.

Reading JSON Data From PHP

Once we’ve serialised the string, we might want to unserialise it again – and the PHP code for that is every bit as simple as the previous example, except that we use the function json_decode() instead of json_encode(). I’ve set the output of the previous script as the input to this one:

$json = '{"starter":["prawn cocktail","soup of the day"],"main course":["roast chicken","fish \'n\' chips","macaroni cheese"],"pudding":["cheesecake","treacle sponge"]}';

print_r(json_decode($json));

This decodes the string and then dumps it using print_r() – the output of my script looked like this:

stdClass Object
(
[starter] => Array
(
[0] => prawn cocktail
[1] => soup of the day
)

[main course] => Array
(
[0] => roast chicken
[1] => fish 'n' chips
[2] => macaroni cheese
)

[pudding] => Array
(
[0] => cheesecake
[1] => treacle sponge
)

)

Note that the data isn’t identical to how it looked when it went in – JSON can’t distinguish between arrays and objects, and doesn’t retain information about data types. So its perfect for a web service where we just want to convey the information, but may be too loose for other applications.

The examples here were taken from a talk I give about consuming web services – you can see all the slides on slideshare. If you have any additions or alternatives, leave a comment!

PHPBenelux: Recap

Last weekend I was privileged to speak at the inaugural PHPBenelux conference in Antwerp, Belgium. Since Ibuildings is partly a dutch company I combined this with one of my regular trips to meet with the people there, visiting both our offices in the Netherlands and catching up with a bunch of colleagues in both locations before making my way to Belgium for the main event.

The conference itself was very well organised and the venue worked very nicely. I liked the hotel (I’m accustomed to London hotel rooms so European ones always seem huge), which was nice and had an English slant on breakfast since sausages were available alongside the cheese and pastries! The venue itself was just across the car park and had plenty of rooms with an open exhibition space which worked nicely – the two tracks were on opposite sides of this space so the footfall for the exhibitors was hopefully good! Full marks go to the crew:

phpbnl10 crew

I gave my talk “Passing the Joel Test in the PHP World” with some updates since I first gave it at PHPNW09 in Manchester. This is a nice best practices talk and although I didn’t have a lot of people in my talk, this was no surprise since Ivo was speaking in the same slot as me with his “PHP and the Cloud” talk, which I STILL haven’t seen! If you are interested my slides are here: http://www.slideshare.net/lornajane/passing-the-joel-test-in-the-php-world-phpbnl10 Thanks to my audience who were great and managed to stay enthusiastic despite my nerves and the late afternoon slot :)

Here’s to PHPBenelux 2011!

Speaking at SuperMondays

I’m delighted to announce that the people at SuperMondays in Newcastle have invited me to speak at their event on 22nd February. For this I’ll be writing a new talk entitled “PHP and Web Services: Perfect Partners” – looking at how PHP is a good fit for web services and how I’m using it both in my day job and in my hobby projects. Visit the event page itself for the full description, a bit about me, and the arrangements for the night. I am warned that they have limited capacity so although admission is free, if you want to go you should register for tickets ASAP!

If you are attending, let me know and come and say “hi” to me on the night! I don’t know this crowd well but so far they are pretty friendly and I’m looking forward to the trip north :)