Welcome! I'm Lorna Jane Mitchell, a web developer, working particularly with PHP, the LAMP stack and related technologies. My main interests lie in working with open source software and building excellent APIs so that data in one system can be used in another. I'm freelance, so if you want to work with me as a consultant, developer, trainer, writer or evangelist, then let me know.


Work With Me

Senior Developer

Need a senior developer? I have years of LAMP experience and love to lend a safe pair of hands to get a team through a tight spot.

API Design

I'm mad about APIs! If you'd like some advice with creating yours or integrating with someone else's, then you're in the right place.

PHP Services

Time for better tools or better practice? Time for a new version of PHP? Let me lend a hand to make your transition go smoothly.

Training

If your team needs to gain or improve their technical skills, I can help. I can work with your team, but I also run public courses, if that suits you better.


From The Blog

Simplest PHP Generator Example

I really like the generators feature that's arriving in PHP 5.5, and since we're now into release candidate releases, it's actually not that far away. I've been speaking on this topic and I thought I'd share my trivially simple code example from my slides.

Writing a Generator

The generators use the yield keyword to feed values out as they are iterated over. In code, they really look a lot like a function (or method):

< ?php
function getValues() {
    // totally trivial example
    yield "Apple";
    yield "Ball";
    yield "Cat";
}

Continue reading

Setting Multiple Headers in a PHP Stream Context

Last week I tried to create a PHP stream context which set multiple headers; an Authorization header and a Content-Type header. All the examples I could find showed headers built up as a string with newlines added manually, which seemed pretty clunky and not-streams-like to me.

In fact, you've been able to pass this as an array since PHP 5.2.10, so to set multiple headers in the stream context, I just used this:

<?php
$options = ["http" => [
    "method" => "POST",
    "header" => ["Authorization: token " . $access_token,
        "Content-Type: application/json"],
    "content" => $data
    ]];
$context = stream_context_create($options);

The $access_token had been set elsewhere (in fact I usually put credentials in a separate file and exclude it from source control in an effort not to spread my access credentials further than I mean to!), and $data is already encoded as JSON. For completeness, you can make the POST request like this:

<?php
// make the request
$response = file_get_contents($url, false, $context);

Hopefully this will help someone else doing the same thing next time (or at least I know I can come back here when I can't remember!), the array approach seems more elegant and maintainable to me.

What Goes in Source Control?

Short answer: everything! However we need some good directory structures and source control configuration to make that a really practical answer, so this article is a quick outline of my usual advice for a good source control structure for a standard web project. The examples are for a PHP project but I'm sure you could apply this to your own language of choice, also. Continue reading


Talks, Articles, Podcasts, and More

Slides

REST for Web Developers


DrupalCon, May 2013
Slides

Tools for Better PHP


php|tek 2013, May 2013
Slides

Upgrading PHP


php|tek 2013
Butterfly

Consuming REST with PHP and Streams


Josetteorama, May 2013
Slides

Debugging HTTP


WhiskyWeb, April 2013
Slides

REST for Web Developers


WhiskyWeb, April 2013