Hi, I'm Liam

I'm a full-stack software developer that loves working with PHP, JavaScript, Laravel and Vue.

Here you can find my latest blog posts as well as any useful tips & tricks, opinions, or other miscellaneous things I might share.

Textarea Slots in Vue Components

by Liam Hammett · 3 minute read · #vue

If you’ve ever tried to build a custom component to wrap around the <textarea> element with Vue, you’ll find that it’s not as simple as you first think to keep the behaviour the same as the native element.

In this post I’m going to quickly show the problem that you’ll likely run into, and a simple solution for it.

Let’s take a look…

Read more…

Run and stop multiple long-running commands from Bash with a trap

by Liam Hammett · 7 minute read · #bash #laravel #cli

Sometimes when working on a project, I’ll always want to run a handful of commands at the same time, some of which may return when they’re done, others might be long-running, like watchers or services actively exposing ports.

This is something that might seem simple to do with a basic Bash script at first, but what if your script has multiple processes running side-by-side and you want to be able to stop them all at once too?

Here we’re going to take a look at how we can achieve this with Bash traps and the single-ampersand operator.

Read more…

Private Constructors

by Liam Hammett · 5 minute read · #php #oop

Private constructors are a pattern found in object-oriented programming languages that prevents the class from being instantiated, except by itself.

The first time I saw this pattern in my programming career, I was confused. It wasn’t immediately apparent why such a feature would ever be beneficial in the real world. How are you meant to use the class if it can’t be instantiated? Why even bother defining a constructor at all if it can’t be called?

It turns out there are a handful of uses that private constructors can lend themselves to. Here I’m going to go over a few purposes they serve. The examples are in PHP but should transfer to any language that supports this feature.

Read more…

My PHP Wishlist

by Liam Hammett · 10 minute read · #php #wishlist

Back when I started using PHP properly in the early 5.0 days, it felt like the language was pretty basic. Other languages were making leaps and bounds every year, and as time went on, PHP seemed to have stagnated. The language wasn’t bad, but it wasn’t as good as it could’ve been.

That all changed this decade. PHP has come an awful long way in the last few years and is once again proving that it’s got what it takes to be a programming language people should take seriously, even outside the web. I’m hugely happy with the direction PHP has taken and the amazing work of the core contributors and the entire ecosystem.

That said, there are a handful of things I would love to see PHP implement at some point in the future. These are a few things that I would’ve liked to be able to use every now and again when the circumstances for them come up.

Read more…

On Leaving Medium

by Liam Hammett · 6 minute read · #blogs

As you can see because you’re already on it, I have a new site that I’ll be posting blog content to at liamhammett.com!

My reason for this change was pretty simple; I want more control over my content.

Medium seems to be given a lot of shit lately, but it holds a special place in my heart for getting me interested in writing. Here I’m going to talk about some pros and cons with the platform that made me come to my decision to move away from it.

Read more…

A Look At PHP's isset()

by Liam Hammett · 9 minute read · #php

isset() is one of the most important tools at your disposal to validate data in PHP. Like the name implies, it is designed to verify if a variable given to it is set, returning a boolean value based on the result.

However, it has some quirks and behaviours that are very much worth knowing as they can easily catch out even experienced developers.

Let’s take a look through how it behaves and what’s so special about it. Even if you’re a veteran PHP developer, hopefully, you’ll pick up something new here.

Read more…

PHP Wishlist: Typing

by Liam Hammett · 10 minute read · #php #wishlist

PHP is a loosely typed language. It doesn’t care what types you throw around. Unless you want it to care.

The language has come a long way in the last several years to bring in a robust type system, allowing developers to enforce types in both function parameters and what a function’s return value is.

For everything else, there’s docblocks, ugly sanitisation and assertion code, and crossing your fingers to hope your function’s API holds up in practice.

Read more…

Supercharge GitHub.com with Browser Extensions

by Liam Hammett · 6 minute read · #github #browser-extensions

As a commercial software developer, my day-to-day work for the last several years has involved working on closed-source software on private GitLab and BitBucket repositories, but that doesn’t mean GitHub has become a stranger to me.

I still spend a good portion of each week on the GitHub website, both for hosting my own personal repositories and looking into open source projects’ code, issues and documentation.

GitHub’s user experience is already pretty great and has only been getting better and better since Microsoft purchased it last year. That said, there are still a few things that are a bit lacklustre and could be improved — but that’s where browser extensions come in!

Read more…

HTML's <button type="reset"> behaviour

· #tweet #html

TailwindCSS <details> plugin

· #open-source #tweet #tailwind

I built a nice looking and fully accessible dropdown menu by using the native <details> HTML tag without a drop of JavaScript in the client.

To build it in a utility-first approach, I created a simple plugin for TailwindCSS.

You can find the plugin over at GitHub.

If Your Blog Doesn't Have an RSS Feed, Don't Have a Blog

by Liam Hammett · 2 minute read · #opinion #blogs

It’s becoming increasingly common lately that people I want to follow are rolling out their very own blog platforms, in an effort to move away from WordPress and centralised platforms like Medium.com.

That’s perfectly commendable, and it often has some fascinating results, but there’s one thing that I come across all the time that destroys people’s chance of me reading their newer content — no RSS feeds.

I use Feedly as my daily RSS reader, and it keeps me up-to-date with hundreds of blogs so I can skim over them and pick out the titles I do want to read. I don’t read every article that comes into it, but I still get to enjoy the content that I like from a variety of writers.

Read more…

Make Infinite Gmail Addresses For One Inbox

by Liam Hammett · 3 minute read · #productivity

Google’s Gmail allows people to get a free email account—but it seems that a lot of people aren’t aware that this gives you access to almost unlimited unique email addresses that will all point to the same inbox, just by making a couple of simple tweaks to it.

Here’s how you can make use of this yourself:

Read more…