Learn More About PHP And The Web Platform!

Struggling with your web server, or to scale your PHP application to meet growing demand?

Whether you're running one server or a whole server farm; whether you're hosting on Windows Server or on Linux.

Learn from Stuart's experience with system design, delivery, support and management to help you do a better job and have an easier time.

Beneath Whitby breakwater

One of the hot discussion topics atm is around the question: who pays a speaker’s costs? And who should pay?

I think there’s a couple of different ways to look at this: from an economic point of view, and then separately from a moral point of view.

The Economic Arguments

Writing and presenting a talk – whether it’s at a user group or a conference – takes both a significant amount of time, and a significant amount of cash.

A new tech talk can take anywhere between 20-40 hours to write, rehearse and polish. That’s 1/2 to a full working week. It takes significantly longer if the talk needs to be accompanied with example code or even a usable code library.

Unless the event is local, you can add in up to two days of travel time on top, plus the time spent at the event itself. And you can add in more days on top to cover both international travel and dealing with jetlag.

It’s impossible to travel without spending money. Whether it’s fuel for the car and car parking charges, or train tickets, or flights, none of that happens without money. And let’s not forget accommodation!

Someone, somewhere, is paying for that time. And someone, somewhere, has to hand over the cash to pay for the travel.

So every speaker – and every employer who lets staff do speaking gigs on company time – has to treat any speaking opportunity as an economic transaction. You may not have ever thought of it in those terms before, but that’s what is happening.

It’s down to individual speakers (and/or their employer) to decide whether or not doing a talk is “worth it” to them. We’ve all got our own motives, and there’s no such thing as a one-size-fits-all approach to it.

I run my own company, and I have over three years now of financial data on whether or not it is worth it or not for me. If you’re curious, the series of talks I’ve been doing to date has cost my firm over £13K in cash paid out, and over £5K in time spent on talks instead of on billable work. So let’s call that about £20K. That’s just for giving talks here in the UK. There’s no international travel at all in that. And it doesn’t account for the many many evenings and weekends I’ve given up of my free time too.

These are just my costs. For several reasons, I am an outlier:

  1. I write a brand new talk for every speaking opportunity, which is very unusual.
  2. I have non-coeliac gluten-intolerance (NCGI). It’s an incurable auto-immune disease. Eating out is very difficult, so I often end up renting an apartment so that I have a kitchen to cook in. That does cost a lot more per-night than a hotel room does.
  3. I’m not tied to an office desk, and can work from pretty much anywhere. I can do billable work on trains and from rented apartments, to reduce the amount of billable hours lost. Many people aren’t that fortunate.
  4. Those costs include the A/V equipment I use to video my talks.

There’s another side to the economic argument, to do with the event itself, and it’s where the moral arguments overlap.

The Moral Point Of View

Generally speaking, events fall into these groups:

  • Community meetups, such as monthly user group nights. Tickets are free (as a rule). Sponsors cover venue costs, free food, and any swag handed out.
  • Community conferences. The tickets aren’t free, but (normally) the tickets are subsidised by the conference’s sponsors. The organisers may (or may not) generate a surplus.
  • Commercial conferences. They’re run to make a profit for the organisers, and it may even be their sole or primary business.
  • Marketing events. They exist to promote the company in one form or another (normally as the third leg in tripod economics), or to provide a platform for attending companies to promote themselves. The economics for these range greatly. Some are run for profit, some are not. Many of them are put on by professional event organisers.

There’s overlap between these groups, and sometimes an event can appear to be one kind (e.g. a community conference) to the attendees when, behind the scenes, it’s actually a commercial conference or a marketing event of some kind.

I think there’s a couple of moral issues here, spread across the different event groups.

The first problem is accessibility. How do we create speaking opportunities for new speakers? Generally speaking, they’re the least likely to have the economic means to pay their own way.

For me, this is important. We need new voices all the time. We need new experiences to be shared, and new perspectives to be shared. It isn’t healthy for the same people to be trotting out the same stuff year after year. It isn’t healthy for our professions, and it isn’t healthy for our communities.

Yes, user groups offer a way to get started. But how do new speakers get from there to other opportunities? Some of them become developer advocates, and (amongst other duties) it becomes their job to speak at events on behalf of their employer. Others find a way to swallow the costs themselves. Most simply drop out, unable to find a way forward.

Then the other problem is around unpaid services. If I’m speaking at your for-profit event, I am (in effect, and often in law too) a supplier. I am supplying a service (a presentation) to your business. Your business is using that service (along with the services of your other suppliers) to make money.

And when your business insists that it cannot afford to pay the suppliers, and trots out an endless stream of creative excuses why, this is in effect a zero-sum game. For them, it’s not about the economics. It’s all about the for-profit event holders believing that they can only have a successful event if they get services supplied for free.

When you come across these people, you’ve got to take a long, hard look at the economic transaction. Are there clear benefits, and are they worth the cost? And is it worth setting aside the moral objections?

Fortunately, as with most things in the software industry, we can look to other (arguably more mature!) walks of life, where this kind of thing has already happened, and learn from them. The music industry is full of stories about pay-to-play gigs, for example.

And there’s always the gold standard. Would a plumber do it, either at all, or on those terms?

Be the first to leave a comment »

JSON Notation for PHP 7.0

Posted by Stuart Herbert on July 9th, 2016 in Uncategorized.

tldr; I’ve been experimenting with the PHP interpreter, and I made a thing …

JSON is by far the most common API request format. I design, build, and fix API servers for a living. I write a lot of API tests as a result.

I often find myself wishing that I could write JSON directly in PHP code like this:

$payload = {
  "hello": {
     "fish": $fishType
  }
};

This would save me a lot of time when I’m copying examples from API documentation or JIRA tickets into my test suites.

You’ll find a patch that adds this to PHP 7.0 here: diff against PHP-7.0 tracking branch.

Some caveats: I’m no expert on the internals of PHP, and this patch is very naive. It probably breaks things in ways that I’m not aware of. It passes the PHP test suite locally, but that doesn’t mean you should be trying this in production.

Here’s some examples of what it allows you to do:

<?php

// this is an array syntax that PHP
// already supports
$a1 = [
  "hello" => "world"
];
var_dump($a1);

// and this should be an array too now
$a2 = [
  "hello": "world"
];
var_dump($a2);

// this is forced to be an array
$a3 = (array){
  "hello": "world"
};
var_dump($a3);

// and this should be an object
//
// you can still use array assignment inside
$a4 = {
  "hello": "world",
  "goodbye" => "everyone"
};
var_dump($a4);

// this should be an object inside an object
$a5 = {
  "hello": {
     "fish": "trout"
  }
};
var_dump($a5);

// create an array of objects
$a6 = [
    {
        "hello": "world"
    },
    {
        "goodbye" => "everyone"
    }
];
var_dump($a6);

// this is an object that contains an array
$a7 = {
    "hello": [
        "world",
        "trout"
    ]
};
var_dump($a7);

// we can still cast nested arrays to objects
$a8 = {
    "hello": (object)[
        "world",
        "trout"
    ]
};
var_dump($a8);

// we can pass data objects as arguments too
function provide($arg1) {
    return $arg1;
}
var_dump(provide({"hello": "world"}));

// we can define and return data objects
// without having to assign to a var first
function returnObject() {
    return { "hello": "world" };
}

Let me know if you’d also find this useful. If there’s enough interest, I’ll see if I can convince someone who is involved in the world of PHP.internals to help me get this turned into an RFC.

Be the first to leave a comment »

Last week, I gave a talk at PHP Cambridge on how to go about setting up and running a positive code review. A huge thanks to Jo for inviting me to speak on this.

We had a great evening looking at the underlying causes of negative code reviews, and what you can tackle to address them. I hope you find the deck useful.

Be the first to leave a comment »

Earlier this month, I gave a talk at the PHP Surrey user group over in Guildford, looking at how to design a functional test.

Be the first to leave a comment »

Over the last four weeks, I’ve been plagued by numerous PHP segfault problems – multiple versions of PHP, on different operating systems, on different hardware, and running completely different codebases.

Yesterday, I ran into a segfault that I couldn’t work around. It is happening with Apache + mod_php, running inside a Centos 6-based Docker container. Docker is hosted on Ubuntu 15.04.

Here are the steps I took to enable core dumps for Apache inside the container, so that I could examine the segfault.

On Ubuntu (the host machine):

  1. sudo sysctl -w fs.suid_dumpable=2
  2. sudo sysctl -w kernel.core_pattern=/tmp/core-%e-%s-%u-%g-%p-%t

That’s it. Your Docker container automatically inherits these settings, and Apache will start coredumping without being restarted.

Why Does This Work?

With Docker, because it’s not a virtual machine in the way that VMWare or VirtualBox is, the container inherits the settings of your host operating system. Inherits, and can’t change them inside the container (which is not ideal).

You have to enable coredumps on your host operating system.

Ubuntu 15.04 ships with coredumps already enabled. Ubuntu also ships with an app that gathers coredumps and ships them off to Canonical for inspection – this is the ‘A system error has been detected’ dialog box that appears all too frequently on a modern Ubuntu system.

Ubuntu’s helper app can’t intercept coredumps that occur within a Docker container, so you don’t have to worry about it in there.

Be the first to leave a comment »

Why We Test: My Talk @PHPOxford

Posted by Stuart Herbert on November 3rd, 2015 in 1 - Beginner, Talks.

Last week, it was my pleasure to present a new talk to the PHP Oxford user group, called “Why We Test”. A huge thanks to Oliver for inviting, and to everyone who came along.

Be the first to leave a comment »

Another Fantastic PHPNW Conference!

Posted by Stuart Herbert on October 8th, 2015 in #phpnw.

I’m back from this year’s PHP North West Conference, and finally have a few moments to talk about what was (yet again!) another excellent year.

I was there to present two talks – Introducing a Quality Model For MVC Applications, and Ways To Measure Your ORM’s Cost. It’s the first time since the php|cruise back in 2004 that I’ve presented twice at the same conference, and brings me up to something like 15 unique talks and workshops presented over the last 11 years.

Are you a good scout? – PHPNW15 Track 3 from phpboyscout

I want to highlight one talk in particular from this year’s conference – Matt Cockayne talking about being a good code scout. This talk got promoted from the Unconference track to a spare slot on the Sunday morning. I’ve been thinking about pitching a keynote about how we all need to be great ambassadors for PHP, and I think Matt’s message would make a great keynote for our community.

Whether I’m speaking or just attending, I always enjoy the PHP North West Conference. Their conference team always do everything that they can to make each conference the best that it can be. In my opinion, the explosion of quality, community-based PHP conferences in Europe owes much to the example set particularly by PHP North West. We’ve come a long way from when I started speaking back in 2004 🙂

I’m really grateful that conference committees here in the UK – both PHP North West and PHP UK – continue to give me opportunities to come and talk at their conferences. Whether it’s about the problems of framework lock-in, component-based architectures, Git workflows, or indeed about driving quality, I’m often talking about things years before the PHP community moves that way. My work is often about solving problems most people don’t yet realise that they have, and that can’t be an easy sell, both within the committees that select talks for conferences nor to attendees when they’re buying their tickets.

This year’s conference may be over, but there’s no rest to be had.

  • I’m already preparing another talk to deliver to the PHP Oxford user group later this month, called “Why Do We Test?” – expect plenty of ethical dilemmas in this one
  • November sees me once again volunteering at Aberystwyth University, coaching 2nd year Comp Sci (and related) students on job hunting
  • I’ll be speaking at PHP Surrey at the start of January 2016, possibly on writing a test suite for PHPFastCGI – you should come just to watch Andrew give his PHPFastCGI talk, it’s cry-out-loud funny

… and I’ve promised both Glasgow PHP and The Edinburgh PHP User Group that I’ll come up and present to them before the end of 2016.

Be the first to leave a comment »

Here is the original blurb for this talk …

Your project has adopted an ORM such as Doctrine because it’s the quickest way to hook your code up to your database. Things are looking up, and your website is about to take off. Aaaand then the first complaints start to come in that your site isn’t coping with the new customers. You can’t find a problem in your own code. Could it be the ORM that’s the problem? How can you tell?

In this talk, Stuart will show you how you can use off-the-shelf open-source tools to work out what your ORM is doing, and whether or not it is the cause of your performance problems. He’ll show you how to measure the database itself and the ORM code, as well as providing useful strategies to reduce the cost of your ORM without having to abandon the ORM altogether. Finally, he’ll show you how you can extend these techniques to other parts of your application, so that you’re never in the dark again.

Be the first to leave a comment »

Here’s the original blurb for this talk …

Your integration, functional and non-functional testing gives you a good idea if your code will work on Production. But how do you go about measuring the quality of code that already seems to work? How do you make that measurement repeatable? How do you share it with clients in government, finance or other large enterprises who are looking for a 3-5 year shelf-life from your code?

In this talk, Stuart will introduce you to SQuaRE, the international standard collection for software quality. He’ll give you a tour of all of the available and upcoming standards in this area, before taking a deep dive into the Product Quality Model from ISO/IEC 25010:2011. He’ll explain what a quality measurement is, how you link them to your project’s quality criteria, and how you incorporate them into code reviews, QA teams and management decisions.

You’ll leave this talk ready to start measuring and improving the quality of your product or service, with the tools you need to not only maintain quality but also to keep increasing it over time, even when faced with staff turnover.

Be the first to leave a comment »

I’ve given several talks to user groups over the last few months, around the topics of testing and performance. I hope that you find them interesting and useful.

When To Mock

Mocking has not only become a mainstream practice in recent years, it has also become the default practice for many developers. In this talk, I present three questions that you should ask yourself first whenever you’re deciding if a mock is the right way to test your code, and some insight into how over-mocking ends up making your tests no better than having no tests at all.

This talk was presented to PHP Dorset in November, 2014.

How Much Does Your ORM Cost?

Whenever you use an ORM, you’re trying to reduce the time it takes to ship your code. But what are you trading in return? This lightning talk introduces the idea that ORMs aren’t entirely “free”, and hopes to start you thinking about how you might go about measuring just how much that ORM is really costing you.

This talk was presented to PHP South West (where I was once the answer to a pub quiz question – my claim to fame!) in April 2015.

The Mad Science of Testing

I’m a firm believer that good testing is also good science, and in this talk, I hope to convince you too. And if we’re going to be scientists, we might as well be mad scientists, because they have all the fun 🙂

This talk was presented to PHP Berkshire in June 2015.

Be the first to leave a comment »
Page 1 of 1912345...10...Last »

This Month

November 2018
M T W T F S S
« Sep    
 1234
567891011
12131415161718
19202122232425
2627282930