Skills Allied to PHP

This post is mostly about a tutorial I will be delivering at PHPNW on October 5th in Manchester, UK, and why I think a tutorial that contains no PHP belongs at a PHP conference

phpnw12 logoIn October, I’ll be delivering a tutorial at the mighty PHPNW Conference which contains very little PHP. Why? Because I think, as developers, it’s our other professional skills that suffer. As a consultant, I work with lots of different teams, and it is very rare for code to be the problem (and the one time it was, it wasn’t the only problem!).

In web development, our biggest challenges are not writing code, we can do that. But getting the code safely from one place to another, with many people’s work preserved, having our platform(s) correctly configured and understanding how to use them, making use of the tools in the ecosystem which will help us improve the quality of our code; these are the big challenges we face, and that’s why I proposed this workshop and why I think all these topics are important. Continue reading

Validating Email Addresses in PHP

A very quick snippet today because I’ve told two people to use this approach in the last few days and both of them told me they didn’t know about it. How to check if an email address is valid in PHP: use one of the Filter functions, like this:


$email1 = "nonsense.something@dottiness";  // not a valid email
$email2 = "[email protected]";  // valid email

$clean_email1 = filter_var($email1, FILTER_VALIDATE_EMAIL); // $clean_email1 = false
$clean_email2 = filter_var($email2, FILTER_VALIDATE_EMAIL); // $clean_email2 = [email protected]

The Filter extension was new in PHP 5.2, but is one of the unsung heroes of the language. It’s rare for me to ever describe one approach as the “right” way to do something – but for validating data, Filter really is excellent, offering both validating and sanitising filters and generally making it super-easy to clean up incoming variables. Many of the frameworks offer equivalents, and I’m sure many of those are wrapping this too.

Two Years of Trading

Two years ago I quite literally gave up the day job. I had no clients, no experience of being anything other than a salaried employee, but I did have an urgent need for change! Two years on I’ve just done the end-of-the-year reporting and I’m struck by how far I’ve come and how much the numbers surprise me (there are no actual numbers in this post, it doesn’t feel appropriate somehow – but there are graphs!). Continue reading

Installing PEAR Packages Offline

As with most tools that work really well, I know very little about PEAR. I mean, I use it all the time, and I love it for getting all the extensions installed that I need for the work I do. But I’ve never made a PEAR package, or channel, and I’ve been happy to leave all those things in the hands of the smart people who have created what we have today.

However I’m now in a situation where I might need to install PEAR packages with a connection that may or may not be working, and I’m not sure exactly which packages I might need, so I wanted to know whether I could use PEAR as my packaging tool even when I wasn’t able to reach the usual channels. And guess what? I can! Continue reading

PHP 5.4 Benchmarks

Today I’m giving my first ever talk at OSCON – about PHP 5.4 (I’ll also be giving my second ever talk at OSCON, about RESTful services; it’s a busy day!). My talk includes some benchmarks which I thought I’d also share here, mostly because I like pretty graphs – and this one is pretty:

graph comparing performance of PHP versions
Continue reading

Lesson Learned: Look in the Pull Request Queue

If you follow me on twitter you might have seen some overexcitement when I managed to edit and compile a vala application recently. I use a great deal of open source tools, but many of them don’t seem open to me, because I don’t have the skills to modify the code. Regardless of that, it’s still vitally important that it is open (this is a whole other post and I’ll avoid that tangent right now). Continue reading

Monday Git Tips

One project I’m working on at the moment involves finding my way around changes in a codebase that isn’t mine – and it’s quite large. I was doing pretty well with a combination of git log and git show and in particular two of my favourite existing tricks:
Continue reading

Pushing to Different Git Remotes

Just a quick tip because I’m working on a different git workflow at the moment with one of my clients, and it struck me that this usage pattern is something I don’t usually write or speak about at all. Most git setups have one “main” repository, and either:

  • there is a gatekeeper that manages merging to here
  • all developers have write access

In this case, I’m working with the second option, so I’m pushing to the upstream repo. I’m also pushing to a live repository as well, so I thought I’d outline the commands I’m using. The setup here is the main github repo, and I have my own fork of that, which is cloned onto my laptop. I can push to both that main repo, which I’ll call “upstream” (because the github documentation does and it makes sense!) and another repo that I’ll call “live”. All in all it looks something like this:


Continue reading