Speaking at PHPNW09

I have experience of PHP conferences from all possible angles – as an attendee, as a speaker and as an organiser. At PHP North West this year I will be taking this to new heights and combining all three roles into a single one-day conference. I have a speaking slot at the event entitled “Passing the Joel Test in the PHP World”, which I’m very excited about. Its a talk that I think brings together the best ideas from a general software engineering world and puts them into the context of PHP development. If you’re wondering what the Joel Test is, then you can read about it on wikipedia.

Having spoken at a few different events now, some local and some quite high-profile PHP conferences (OK, so php|tek – the event of the year!), I’m really delighted to be bringing my ideas to the local conference that I help to organise and attached to a user group full of bright and interesting people. The experience of launching a call for papers, submitting my own abstracts, and then trying to figure out where it fits in when evaluating the CfP was a bit split-personality but with Jeremy’s input we decided this was a good fit – and I’m looking forward to delivering it!

The event itself is in Manchester, UK on Saturday 10th October and there is only one week remaining on the early bird ticket price!! So all those people who think its ages away and you’ll sort out arrangements nearer the time – you have been warned. The schedule is world-class (quite literally, these speakers do speak right around the world), and the price is pocket money (50 GBP + VAT until 11th September). As well as the technical content you get a fun weekend in Manchester, plenty of social activity, there’s more geekery happening the following day and all attendees get a 12-month subscription to php|architect magazine to keep them learning all year long. Now you’re persuaded – you can buy you tickets here and let me know to expect you!

PHPNW is the highlight of my year – I hope to see you there :)

PHPNW: Schedule and Crowd-Sourcing

Plans for the second annual PHP North West conference (Manchester, 10th October) are coming along rather nicely, so I thought I’d share an update and some headline news. First of all – tickets cost 50 GBP + VAT. This is about 57 euros or 81 dollars. I don’t know where else you can buy conference attendance for that kind of money, we even have concessionary prices for students, OAPs, anyone else who can persuade us they deserve it. So – buy your tickets and come join in the fun!

Since I last posted here we also published the schedule. We were overwhelmed by the quality of the call for papers and there are some cracking sessions, excellent speakers, and lots of overlap between the two! Already grumbling can be heard about good sessions which clash with one another … which is rather a wonderful problem to have :)

Finally, this year PHPNW is expanding and has added an informal schedule on the Sunday morning since we know lots of people will be staying over. This will run from 9 til 1 and we’ve put out a call to ask what people would like to see on the schedule. So far a few regulars have already made themselves heard and we’re looking forward to seeing the outcome of crowd-sourcing a schedule in this way! The Sunday event is at Museum of Science and Industry, which a fun place to go for geeks and, like the morning event, is free entry!

Hoping to see lots of you there at the conference this year – last year’s event was brilliant with an excellent atmosphere, and this year looks to be better again. I can’t wait :)

First Steps with bzr-svn

I’m an SVN nut – love it, use it, talk about it at any opportunity, can’t physically write code without it. But as a telecommuting developer who is sometimes travelling around, I’ve been thinking for a while that one of the distributed systems would really make more sense. I tried git ages ago and decided that I just wasn’t smart enough to use it; I’m so comfortable and confident with subversion and it is such a change.

I know there are alternatives out there, I saw a talk about bzr at LUGRadioLive last year and I have some canonical-associated friends who use it so I know the community is good and I can get some help if I need it. I confided in a fellow developer that I’d struggled with git, but that I’d also read that bzr would be more subversion-like which seemed ideal for me since that’s my background. His response? “No, bzr isn’t easier for people coming from SVN, bzr is just easier“. So I figured I’d give it a go.

I’m an ubuntu user so I installed the bzr, bzrtools and bzr-svn packages, and read the user guide – the user guide is absolutely excellent and I wish every tool in the world had instructions like these! Anyway here’s a quick outline of how I got started and used bzr against my existing SVN repository (it seems too much like hard work to start migrating repos before I’ve decided if I like the tool).

Who Am I?

Tell bzr your name and email so it can credit your commits to you:

 bzr whoami "Lorna Mitchell "

Good start :)

Checkout from SVN

There are several ways to set yourself up to work with bzr-svn, I chose the simplest, and checked out from SVN using bzr, then branched locally and worked on that. First we initialise a directory as a bzr repository:

bzr init-repo --default-rich-root snapshot

Then I actually did the checkout.

bzr checkout http://svn.rivendell.local/snapshot/trunk trunk

So at this point I have a current working copy of code.

Bzr Branching

So that I could work locally and commit at intermediate stages between commits to the SVN repo, I then made a local bzr branch of this checkout. This is the bit that’s a bit different to subversion, the branch is just local to you, more like a working copy. It was quite easy:

bzr branch trunk working

So I’ll now make my changes in the working branch I just created, this becomes my web root if its a web app for example.

Comitting

Using the “bzr commit” command from the branch we created (“working” directory in the examples) only commits locally to the branch. You can do this as many times as you need/want to until your feature is ready (or maybe until you can get back to a connection).

Updating

I realised at this point that I needed to update from the repo to pick up some changes someone else had made, to do this I needed to update my checkout and then pull the changes into my branch:

cd ../trunk
bzr update
cd ../working
bzr pull

To give a clearer idea of how this all goes togehter, I drew a diagram of the repo, the checkout, the branch, and how the process works to get between them all (click to see it at a sensible size):

Status

The “bzr status” command shows what changes are local to the current directory.

Conveying Changes Back To Repo

I made a couple of changes in my working directory and then wanted to put these back to the repo. So from the checkout (“trunk” directory in my example), I merged the changes in and then committed.

bzr merge ../working/
bzr commit

My changes were then in the SVN repo exactly as normal, bzr-svn means extra functionality for me but nobody else necessarily needs to change tools and all the hooks and backup routines and everything that are already in place for this repo can be kept. I’m happy with that outcome!

Next Steps

This is a very basic usage of bzr, really I’m only recording my own experience to make these concepts clearer in my own mind. I plan to do a lot more with this tool and will keep blogging as I go along. Comments, corrections, suggestions and questions are all very welcome – add a comment :)

PHPWomen Merchandise

A few weeks ago, phpwomen.org put out an announcement about merchandise. When we first started the group (almost 3 years ago, believe it or not) we printed t-shirts and gave them out at conferences. Once the various founder members and a few benefactors had paid for a set of t-shirts each it became clear that this wasn’t a sustainable venture. So, after much happening in the background getting set up as a non-profit and getting a bank account (thanks mostly to lig!) and a bunch of time spent sorting out two spreadshirt shops (thanks Elizabeth!), it is now possible to buy merchandise online in both North America and Europe! The big problem with cafepress is the shipping costs for everyone outside of North America so spreadshirt seemed like a better option … still not ideal for our members further afield however and perhaps we can work out some better alternatives over time.

So, with great excitement I ordered my new phpwomen shirt (in girl fit!) – and here it is:

New PHPWomen Shirt

Note: This is the large size … I’m not small but I’m not really that large either so order a bigger size if you are ordering the girl fit shirts.

So, what are you waiting for? Head over to the announcement post and follow the links to order your shirt and support the organisation – just in time for the autumn conference season!

A Bit About Burnout

I’ve been thinking a lot lately about burnout, I’ve had a couple of encounters with it in the last year myself and also a few people close to me have found themselves struggling internally after working too hard. I don’t really have any advice to give – the advice I offer to myself is to know my own limitations, know when I am close to them and need to tread carefully, and to stand up for myself against the sources of stress or overwork if the need arises.

However it happens, the question a burned-out person seems to ask is “how long will I feel this way?” and there is no quantifiable answer, and no guaranteed cure for that dragging fatigue. Most of the advice I’ve heard revolves around “get a hobby” – this time around I realised what I needed to hear was “give yourself permission to waste time”. The first one I don’t have a problem with, anyone who knows me knows I’m a live wire and always doing 6 things at once. The second one … that’s the killer.

Earlier in the year I did a lot of travel for a particular work project, at a time when my diary was already pretty full and I was preparing for a big conference. With one thing and another, by the time it was all over, I realised I needed to make some changes. Lots of elements of my life – friends, family, relationship and health – had all taken a beating while I was off dealing with all that I needed to do, and I realised there was a lot to do to get myself to where I wanted to be on all those other fronts. Last week I realised that although it took 10 weeks, now I feel like myself, finally picking up the strands of hobbies and having the energy to contribute to things that once interested me. Its not a big chunk of time to spend “healing” and I am glad now that I did step away, allow myself to vegetate and chill out with those close to me instead of being driven all the time to the next thing on the list.

Most of all – I hope other people come through the experience as unscathed as I have, and that I learned something for next time.

Adding PUT variables to Request Object in Zend Framework

When I wrote recently about testing web services within Zend Framework, I missed out a really key piece of information! I didn’t explain how I was reading the PUT vars in my controller code in the first place – so I’ll rectify that omission now.

Its very simple: I have extended Zend_Controller_Action with my own, and all controllers inherit from here. This has a routeAction() which grabs the incoming variables from a PUT request and sets them as parameters within the usual $this->getRequest() scope, then forwards on the request. Here is my class:

class My_Controller_Action extends Zend_Controller_Action
{
    public function routeAction()    
    {
        // handle grabbing PUT vars
        if($this->getRequest()->isPut()) {
            parse_str($this->getRequest()->getRawBody(), $params);
            foreach($params as $key => $value) {
                $this->getRequest()->setParam($key, $value);
            }
        }
        $this->_forward(strtolower($this->getRequest()->getMethod()));
    }
}

So in my controller code, I simply call out to $this->getRequest()->getParam(‘name’) or whatever, and in my tests I can set those parameters as I showed in my other article.

I hope this makes sense, its one of those things I set up once and use a lot (and now I’ll be able to refer to how I did it!), if you have any queries, comments, improvements or if this helps you then please leave a comment – I haven’t come across anyone else doing anything similar but I know there must be, so let me know!

Using Zend_Test for Web Services

Recently I had cause to develop a web service and so I wrote some tests to go along with it – or I was about to. When I looked at the asserts available in Zend_Test, they were all geared towards HTML/CSS output – but we can test just as effectively on another output.

Using Zend_Test, I set up the request object I wanted to send, and dispatched it. Then I retrieved the body and, since this service returns JSON, I json_decoded it. This gives me an object – and I can go ahead and use all the functionality of PHPUnit, with or without Zend_Test’s additions, to test my service. Its perhaps easiest to show this in a few steps.

Setting up the request object

The idea here is that you set up any parameters you need to including the HTTP verb to use and cookies if needed, then despatch the request. Here’s a few examples, first a simple GET method, with a cookie.

        $request = $this->getRequest();
        $request->setMethod('GET');
        $request->setCookie('token','xxxx');
        $this->dispatch('/user/24');

Including data with a POST request:

        $request = $this->getRequest();
        $request->setMethod('POST');
        $request->setPost(array(
            'name' => 'new user',
            'organisation' => 49
            ));
        $this->dispatch('/user');

This is a REST service, so I also tested PUT and DELETE methods. DELETE just needs the setMethod() call since it doesn’t have any data with it, but PUT was a bit trickier – here’s an example of what I used:

        $request = $this->getRequest();
        $request->setMethod('PUT');
        $params = array('name' => 'Harry Potter');
        $request->setRawBody(http_build_query($params));
        $this->dispatch('/user/48');

Decoding the Response

This is the easy part, all I do is check the status code is what was expected, and then decode the response. My web service returns JSON so this part of each test looks something like:

        $this->assertResponseCode('200');

        $response = json_decode($this->getResponse()->getBody());

Testing the content of the response

Here we get into classic PHPUnit territory and simply use the assertTrue and assertEquals calls we’d use when testing anything else, an example is included for completeness:

        $this->assertEquals($response->contentType, 'user');
        $this->assertTrue(is_numeric($response->id));
        $this->assertEquals($response->name, 'new user');
        $this->assertEquals($response->organisation, 49);

In Conclusion

By combining the request/response awareness of Zend_Test with standard PHPUnit testing strategies, its easy to test web services as well as web pages. I hope the examples are helpful – if they help you or if you have anything to add, then leave a comment!

The Writing on the Wall

I’m currently redecorating in the house and have moved my office up to the top floor temporarily – I like it up here but its a flight of stairs to the bathroom, two to answer the door and three to get a cup of coffee and I also have no wired network! I started stripping the wallpaper off my real office (which will be my office again once its done), and look what I found:

office What's under the wallpaper?

Can you tell what it is yet? Magnificent ? In His Flying Machine

I think this room is going to be a bit of a mission, I have one wall with half a missing skirting board which has had its fireplace plastered up twice, one where the plaster is falling off much faster than the old wallpaper, and one outside wall which is damp and in such bad shape I actually had to go outside and check it looked OK from there. And this is is the smallest room in the house …

Customising Screen-Profile Files

I wrote a while ago about the new version of screen in Ubuntu Jaunty. Screen is an application which lets you run lots of tabs inside one terminal window, then disconnect from screen and reconnect again later. You can turn on and off a whole bunch of notifications which appear inside screen, and I also added the pink tabs I used with older versions of screen.

The tabs line is the one in the profile file which starts “caption always”.

caption always "%{wk}%H%{Bk}|%{Mk}%?%-Lw%?%{km}[%n*%f %t]%?(%u)%?%{mk}%?%+Lw%? %=%{Bk}"

I also altered the “hardstatus string” line, which holds lots of placeholders, to remove the clock – I run screen on my laptop inside KDE mostly, so I already know what time it is. Annoyingly this isn’t customisable via the menus but I edited my profile file to get rid of it – here’s the diff

29c29
< hardstatus string '%99`%{= kw} %100`%112`%= %102`%101`%114`%115`%108`%113`%119`%117`%118`%116`%106`%104`%103`%105`%107`%Y-%m-%d %0c:%s'
---
> hardstatus string '%99`%{= kw} %100`%112`%= %102`%101`%114`%115`%108`%113`%119`%117`%118`%116`%106`%104`%103`%105`%107`'

The only thing annoying me now is that screen seems to constantly redraw itself, so Konsole thinks there is activity in that screen, when there isn’t. Suggestions on stopping this or more ways you can customise your screen file are gratefully received – just add a comment!

Upgrading Subversion Server to 1.5

I’m really excited about the magic merging features in the newer subversion versions at 1.5 and later. I’m still figuring out which are actually useful, more on those another day, but I wanted to mention something I ran into when upgrading my server.

Some time ago I upgraded the subversion server to subversion 1.5, and the clients that use it are probably mostly on 1.5 as well. We haven’t had any compatibility problems between versions on this upgrade, which is good news since a few versions ago there was a release which caused any newer client to render the repo unreadable by any older client. Predictably someone in the office upgraded their client one day and it took us a good few hours to work out why subversion had stopped working!

The Subversion 1.5 upgrade doesn’t turn on all the 1.5 features by default, but will upgrade to 1.5 and allow older clients to continue to work with it. If you want to upgrade to the 1.5 features though, you’ll need to make sure that all users have clients of version 1.5 or later, and then upgrade the repo by running:

svnadmin upgrade

Once this is done you can start using the new merge tracking features in subversion – enjoy!