I’ve added all the past talks of note (made much easier by my tendency to blog and tag all these experiences!), let me know if you have any questions or comments!
Author Archives:
New Netball Rules
The new rules look AMAZING … things you don’t imagine we’d ever manage to introduce in mainstream competition. There’s quite a few but for me the big ones are:
- Goals scored from outside the shooting circle not only count, but count as double points
- The coaches can coach while the game is in progress (banned at many levels of competition
- Centre passes are taken by the team that just conceded a goal
- Substitutions can be made while the game is ongoing (how is this going to work? I can’t imagine!)
Looking forward to seeing how these rules play out and perhaps having them introduced in the leagues I play in eventually!
Speaking at PHPNW09
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
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 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
So, with great excitement I ordered my new phpwomen shirt (in girl fit!) – and here it is:
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
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
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
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 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 …