I enjoyed Mohamed's post on using PHP and Go to have the best of both worlds.
By employing a polyglot architecture, we get the best of both worlds. PHP provides the development speed required to compete in a hyper-growth market, while Go provides more efficient resource utilization.
Another good quote from the introduction of his PHP to Go course:
PHP may be slow and memory hungry when compared to a compiled language, but that's not a result of a bad design.
It's like this by design because of all the choices it makes on your behalf to conceal complexity.
I also recommend his post on Twitter about the business decisions behind cutting costs on infrastructure.
Data providers can be a perfect fit to assert a lot of expectations without writing a full test for each, but they can slow down your tests unnecessarily.
Next on my PHP wishlist are nested properties. This idea is less realistic than others, it's more me thinking out loud. I don't have a good syntax proposal for this, and I'm not even sure it's the best solution for my problem. But it's the best I've come up with so far.
Putting this in a blog post because I always forget.
To view PHP logs from Laravel Valet:
To view NGINX logs from Laravel Valet:
Freek shares a few patterns we employ to let developers override behaviour in our packages.
One of the ways we keep maintenance burden low is by making our packages customizable. In this blog post, I'd like to cover some of our best tips to make a Laravel package easy to customize. Some of these tips will apply to regular projects as well.
Is it weird to have a favorite operator? Well, the pipe operator
|> is mine. Not only does it look cool, it opens a world of possibilities for better code.
Static methods tend to have a bad reputation in PHP, but I believe (stateless) static methods are underused. In static functions, there's no internal state to take into account.
Calculator::sum(1, 2) only depends on its input, and will always return
While researching for another post, I came across an article from Mathias Verraes that already says everything I wanted to say.
It is stateless, it is free of side effects, and as such, it is entirely predictable. You can call the exact same function with the exact same argument as often as you like, and you will always get the exact same result back.
I shiver at the sight of a function packed with too-many-to-read-at-a-glance arguments without a description.
A few weeks ago a spec change for an application we're working on forced us to refactor part of the codebase. It was food for thought about the flexibility granular interfaces provide, and choosing the right abstraction at the right time. This is a short writeup on the thought process we went through as we updated our logic to support a new feature now and allow more options in the future.
Our Blink package is marketed as a caching solution to memoize data for the duration of a web request. Recently, we came upon another use case for the package: to execute something once and only once.
I created the original Spatie guidelines site three years ago. Last month, we consolidated a few of our subsites to our main spatie.be site, including the guidelines.
A few weeks ago, TJ Miller introduced me to highlight.php by writing a Parsedown extension for it. Highlight.php does the exact same thing as highlight.js: they both add tags and classes to your
code blocks, which enables them to be highlighted with CSS. The difference is, highlight.php does this on the server.
Server side rendering is a hot topic when it comes to client side applications. Unfortunately, it's not an easy thing to do, especially if you're not building things in a Node.js environment.
Let's review some server side rendering concepts, benefits and tradeoffs, and build a server renderer in PHP from first principles.
Laravel 5.6 adds the ability to register alias directives for Blade components. Let's review some background information and examples.
Christoph Rumpel published his revamped site last week, built with Laravel and Tailwind CSS. He based the site's architecture on my personal site (yeah, the one you're reading now). I open sourced it about a year ago, and I'm glad to see that it provided value to someone!
Read the full article on Christoph Rumpel's new blog.