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.
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.
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.
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.
😱 I just learned you can paste an image from your clipboard directly into GitHub comments/issues and it'll upload it and insert the markdown for you manually, awesome!
One thing I find myself using all the time is the #chrome searchbar to just type in Jira ticket IDs to instantly get there - so so easy when you know what the ticket is. pic.twitter.com/p1oADlHM1P
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!
For all the powerful and complex stuff @NotionHQ can do, I find the template I use the most is just a button to add a new list item. Super simple to just add random thoughts and note to a list without thinking where exactly to put them. pic.twitter.com/5LnSXbavFM
Interesting little #php technique I came across to get the main application's directory - using a class you know will exist in the same place and reflection to find out the path. pic.twitter.com/KOZVz76z4z
@SassCSS can be quite powerful too. It may not be as pretty as it being done in JavaScript, but you can make a couple of mapping tables and generate all the slightly different utilities you want... like spacing utilities:https://t.co/JNfz7PPVtkpic.twitter.com/kp4TczQBaL
TIL <button type="reset"> changes the form fields back to what they were originally — for some reason I always thought it would just make all of the values of fields in that form blank. Maybe it's better to label it "Discard changes" or something a bit more verbose in context?
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.
A little more polish to get the alignment and colours sorted out, as well as flipping the caret on open — just a couple of years ago it would've been completely unthinkable to build an accessible dropdown component like that without the use of JavaScript pic.twitter.com/qPaygfh29p
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.
How an email address is split into two parts; the username and domain
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.
I use shortcuts on my devices all the time. Shortcuts are great, they let you perform complex actions in a fraction of the time — time that adds up a lot over time when you’re using the device for 10 hours a day.
In this post, I’ll be going over some of the typical shortcuts I have set up and use on a daily basis, and some of the applications I use to get them working.
Being colourblind, one thing I really love about @sip_app is that I can just point at a pixel on the screen and immediately be told what colour it is — might seem like a small thing but this has been a pain for years until now pic.twitter.com/taIJ5XbqdW
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: