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.

Laravel Blade Helpers

by Liam Hammett · 3 minute read · #open-source #laravel

Laravel’s Blade templating engine offers a ton of convenient directives you can use to make your view files beautiful and abstract anything that may be too complex or verbose to live inside HTML. It even gives a really handy way to add your own custom directives using the Blade::directive(…) method.

However, the callback in custom directives only receives a single parameter - the raw string expression from the view file. It seems to be rare that developers actually parse the contents of the expression itself within the directive, opting instead to pass the entire expression as arguments to a helper function or a method on another class. For example:

BladeHelper::directive('uppercase', function($expression) {
    return "<?php echo strtoupper($expression); ?>";
});

Read more…

Black Friday 2018 Deals for Laravel Developers

by Liam Hammett · 6 minute read · #laravel

It’s that time of the year again, and over the next few days there will be some awesome deals in all sorts of areas - retail and tech especially. As a Laravel developer, there’s a lot of goodies to get your hands on for some insanely discounted prices!

Here I’ll try to sum up some of the great deals you might want to get your hands on.

Laravel Nova - 30% off

Read more…

Screen-reading dates

· #tweet #a11y

What might look perfectly readable to the human eye may not be picked up very well by screen readers.

As you can see, in this example, VoiceOver thinks the “2018 - 15” section is a single unit that should be read as “2018 to 2015”.

To give screen readers a fighting chance, you should always make sure to use more semantic elements available in HTML, such as <time>, if applicable.

Why I Prefer Discord Over Slack

by Liam Hammett · 8 minute read · #opinion #discord #slack #chat

I’ve used more than my fair share of chat apps and solutions in the past, for both personal and professional use. AIM, MSN, Skype, IRC, Pidgin, HipChat, and Mattermost — to name the few that I’ve used for at least a year.

But over the years, they’ve all mostly faded away with two standing at the forefront: Slack for professional use, and Discord for gaming and casual use.

I use both on a daily basis, but strongly prefer Discord out of these two options, for both general use and coding discussion. Here I’m going to explain why Discord is better.

Read more…

CSS Filter Utility Classes

by Liam Hammett · 4 minute read · #css

(Ab)using CSS variables to apply multiple filters with one utility

Note: This article has a CodePen demo with inline examples, check it out towards the end.

The filter property is a bit of an oddity when it comes to CSS.

Read more…

Catching an exit(); in PHP

by Liam Hammett · 1 minute read · #php

What do you do when something goes wrong in your PHP application? Probably throwing an exception, so it can be caught at a higher level and handled appropriately.

What happens when instead of throwing an exception, an exit(); is executed? Can you catch it?

Read more…

Bitmask Constant Arguments in PHP

by Liam Hammett · 6 minute read · #php

PHP has a handful of core functions that can accept boolean arguments in the form of constants that have a binary value.

These can be combined together in a single function argument, essentially passing multiple boolean flags in a very compact manner.

They work a bit differently to how most people implement options in their userland functions, so let’s take a look at how they work.

Read more…

Throttle Simultaneous API Requests with Laravel

by Liam Hammett · 2 minute read · #open-source #php #laravel

Laravel comes with a handy ThrottleRequests middleware out-of-the-box that blocks users of an API from being able to send more than a particular amount of requests within a defined amount of time.

This is extremely useful for preventing an API from being abused by spammed requests, but isn’t suitable for every use case.

What about an API call that takes a lot of limited processing power, or performs an action that simply can’t be running twice at the same time?

Read more…