Have you ever wished that a PHP class had another method on it that you’d like to use? Laravel makes this dream come true through its concept of “Macroable” classes.
Macroable itself is the name of a trait Laravel comes with that is applied to many of the framework’s own classes.
This trait allows you to call a static “macro” method at runtime to add a new method to the class by executing a closure. …
Black Friday and Cyber Monday deals have already started for 2019, and if you’re a PHP or specifically Laravel developer, there’s a lot to look forward to, especially if you’re looking to expand your knowledge and pick up some new skills on the cheap.
In the following link, I’ll be keeping you up-to-date with the best and latest deals to keep an eye on — it’s the only time of year with these kinds of huge price drops, so don’t miss out.
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.
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…
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. …
isset() is one of the most important tools at your disposal to validate data in PHP. As 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.
Despite looking like one,
isset() is actually NOT a…
Note: This post has been moved to my personal website, check it out to read the most up-to-date version and keep up with my latest postings: https://liamhammett.com/php-wishlist-typing-LkoZazl3
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…
Note: This post has been moved to my personal website, check it out to read the most up-to-date version and keep up with my latest postings: https://liamhammett.com/php-wishlist-operator-overloading-wEQXAr4p
Note: Since writing this post, I came across the
pecl-php-operator extension on GitHub that does exactly what I described in this post, it’s awesome!
Note: This post has been moved to my personal website, check it out to read the most up-to-date version and keep up with my latest postings: https://liamhammett.com/supercharge-githubcom-with-browser-extensions-geQEkzM0
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…
Note: This post has been moved to my personal website, check it out to read the most up-to-date version and keep up with my latest postings: https://liamhammett.com/if-your-blog-doesnt-have-an-rss-feed-dont-have-a-blog-edr7LzWA
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…
PHP developer based in the South-West of England.