Guzzle Segfault

Have you ever been working with Guzzle, php-fpm and Nginx and then as soon as you send a request via the Guzzle client you get a "502 Bad Gateway"?

Well, that's how I spent 2 working days this week, absolutely everything in our code looked fine, running it via a PHP script on the terminal wasn't a problem, but as soon as we used the same code within our development Docker containers, boom, 502.

After drilling down into the code for the Guzzle CurlHandler for what seemed like an age, I eventually noticed something that piqued my interest: Guzzle was trying to write to write to php://temp if you don't provide a sink option in the construction of the Client (the code that covers this:

This got me thinking, "I wonder if Alpine Linux creates the same /tmp folder that Ubuntu et-al do?", turns out, no they don't. After creating the /tmp directory to match where PHP believed the stream for php://temp should go everything worked like a least from the Guzzle standpoint.

I hope this helps someone else out there, but if not, it's at least a reminder for me if I ever see Guzzle segfault on me again...

Goals for 2017

Since the first notes of Auld Lang Syne were struck to signal the start of 2017 I've been trying to work out what my goals (or "resolutions") for the year ahead would be.

Well, it's only taken me 10 days but I think I finally know the things I want to focus on for this year.

Read 10 books (at least 4 being technical)

This goal may not seem all that high for most people, but combined with working, watching TV with my wife, playing video games, and working on things at home that I want to do, I've found it incredibly difficult to squeeze reading in as yet another activity in my week.

That's why this year I'm setting myself the goal of reading 10 books, 4 of which are non-fiction technical books to increase my knowledge.

You can follow my progress (if that's your thing) on GoodReads

Waste less

One of the things I've noticed over the last 3-4 months is just how much I waste, be that money, time, food or anything else.

This year I just want to waste less, rather than going out for lunch 5 days a week, bring food I've already brought/cooked from home at least 3 times a week.

Rather than spend an hour trawling through the inevitable cycle of Facebook, Twitter, Imgur, Twitter, Imgur, Facebook spend that time working towards my reading challenge, working on that cool new side project I'm doing or just chilling out in front of the PS4 or Netflix. Anything rather than nothing.

Quality over Quantity

For anyone who knows me, going to concerts is a big deal for me. It is probably the most social thing I spend my time doing. In the last 12-18 months I've been to at least 1 concert every month (festivals inclusive).

This year I've decided I'm going to be much more selective about what I go see. Rather than go see a band I've seen 4 times since they released their most recent album (no matter how good they are) I'll skip them this time round, maybe go see a local band who are playing their first headline show, or a band travelling for their first UK tour in 3-4 years.

I want to be more selective over who I see, create more memories, rather than it just becoming "another gig".

Symfony Request Attributes

If you're working with the Symfony framework the chances are at some stage you've worked with the Request class from the http-foundation component.

The chances are that to get route parameters you've done something close to the following


namespace Demo\Controller;

use Symfony\Component\HttpFoundation;

public function controllerAction(Request $request)
  $routeParam = $request->get('route_key');

This code is really simple to understand and use, but it means that under the hood Symfony is having to check query strings, post variables and route attributes to get that one parameter, which is not ideal from a speed perspective (note: the difference will be milliseconds, not much of a concern to many people).

This week I learned the easy way to pick up route parameters (in what I believe is a quicker, and definitely more explicit way)


namespace Demo\Controller;

use Symfony\Component\HttpFoundation;

public function controllerAction(Request $request)
  $routeParam = $request->attributes->get('route_key');

Using the attributes property from the request we have told the Request class to get pre-set keys managed by the route (or any middleware class) rather than using the common query or post attributes

My First Post...Again

Hello again!

Once again I've decided to move my blog/personal website to ANOTHER platform, this time I've went for Sculpin, so far, so good...