I crashed the web servers of a $100M+ multi-national corporation

A great story by Derick Bailey of Watchmecode.net

The important lesson, ..., was that I owned up to the mistake, dug in and fixed it, and learned how to avoid the problem in the future. I was, in his mind, a better developer at the end of that day. I had survived a catastrophic crash of my own making and I had fixed the problem, learning some very valuable lessons in business down time and in code that day.
http://derickbailey.com/email_archive/i-crashed-the-web-servers-of-a-100m-multi-national-corporation/

Read more

Join 9,500+ smart developers

Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

No spam. Unsubscribe anytime. You can also follow me on X.

Do not trust cat at the command line

In this excellent post Matthias explains why you can't put all your trust in cat when inspecting a file:

https://ma.ttias.be/terminal-escape-sequences-the-new-xss-for-linux-sysadmins/

Let's all agree to never trust anything that has been posted on the internet without very thorough inspection. And let's especially agree to never run an arbitrary command or script found on the internet, without really close inspection.

Read more

Redirect every request in a Laravel app original

by Freek Van der Herten – 1 minute read

I recently had to redirect every single request in a Laravel app. You might think that would be as easy as this: Route::get('/', function() { return redirect('https://targetdomain.com'); }); But that'll only redirect the "/" page. All other requests will return a 404.…

Read more

A middleware to check abilities on the route level original

by Freek Van der Herten – 1 minute read

Laravel's native authorization functionality allows you to define abilities a user can have. There are multiple ways to check if a user has a certain ability: via the facade, via the user model, within blade templates and within form requests. What Laravel doesn't provide out of the box is a…

Read more

Functional programming design patterns

In object-oriented development, we are all familiar with design patterns such as the Strategy pattern and Decorator pattern, and design principles such as SOLID.

The functional programming community has design patterns and principles as well.

This talk will provide an overview of some of these, and present some demonstrations of FP design in practice.

Watch it on Vimeo.

Read more

The Star Wars Holiday Special

Like most geeks out there I'm a big fan of Star Wars. Many will agree that the original trilogy is far superior to the prequel triology. Until yesterday I thought Episode II was the worst movie of the entire series. But then I found out about the holiday special.

The Star Wars Holiday Special was made in 1978, a year after the original movie. The storyline (quoted from Wikipedia) sounds quite good:

... Chewbacca and Han Solo visit Kashyyyk, Chewbacca's home world, to celebrate Life Day. They are pursued by agents of the Galactic Empire, who are searching for members of the Rebel Alliance on the planet. The special introduces three members of Chewbacca's family: his father Itchy, his wife Malla, and his son Lumpy, though these names were later explained to have been nicknames, their full names being Attichitcuk, Mallatobuck, and Lumpawaroo, respectively.

During the special, scenes also take place in outer space and in spacecraft including the Millennium Falcon and an Imperial Star Destroyer. The variety-show segments and cartoon introduce a few other locales, such as a cantina on the desert planet of Tatooine and a gooey, reddish ocean planet known as Panna.

Luke Skywalker, Han Solo, Chewbacca, Princess Leia are all in there. But their presence absolutely doesn't hide the fact that it is a terrible terrible movie. Episode II is a genius work of art compared to this pile of crap. In it's day the movie received mostly very negative reviews. George Lucas agrees. He said this about the christmas special: "If I had the time and a sledgehammer, I would track down every copy of that show and smash it."

See the special for yourself on YouTube. But I recommend you don't.

To restore your faith in Star Wars watch the trailer of episode VII . Very much looking forward to that one.

https://www.youtube.com/watch?v=wCc2v7izk8w

Read more

Introducing Laravel Spark

Matt Stauffer wrote another excellent article on Laravel. This time he gives a tour of Laravel Spark.

In case you're still having a bit of trouble understanding what Spark is really about, Spark is a tool designed to make it quicker for you to spin up SaaS applications, and it handles user authentications, plans and payments and coupons, and team logic.

Most SaaSes have these same components: user accounts, Stripe-based payments, and different payment plans. And many have payment coupons and team payment options.

Rather than re-creating this functionality with every new Laravel app you create, just use Spark, and you'll get all that and a free SaaS landing page to boot.

https://mattstauffer.co/blog/introducing-laravel-spark-a-deep-dive

Read more

Using the dataset property in JavaScript

In plain old JavaScript you can get the data attributes of

[code language="html"]

lorum ipsum
```

like this

[code language="javascript"] document.getElementById('test').getAttribute('data-news-item-id');



But did you know there's a alternative way of doing this by reading an element's dataset property?

[code language="javascript"]
document.getElementById('test').dataset.newsItemId;

Notice that the values can be accessed by camelcasing the name of the data attribute. You can also write to datasets to change values of data attributes. Read the informative helpful article on MDN to know more.

Read more

ActiveRecord and the Beauty Lost in Translation

If you're going to read one article on ActiveRecord vs Data Mapper let it be this one by Matthew Machuga.

The next time you come across the ActiveRecord vs. Data Mapper argument, or ones like it, be critical of what is being said. If it impacts your work in some way, do some research to find out if what is being said is true or if it has been something lost in translation. Don't feel bad for using a pattern that has spread across multiple languages and ecosystems successfully, and is probably the reason we have most of the web frameworks we do today. While the ActiveRecord existed well before Rails, it was Rails that gave it a beautiful API and made other frameworks like CodeIgniter, Laravel, .NET, Fuel, Django, etc want to have something comparable.

If you use Eloquent, ActiveRecord for Rails, or any other AR ORM, make sure you know that you are not alone. You are in good company of many, many developers who use it successfully day-to-day. However, if one day you choose to use a Data Mapper implementation or something else, then you will still be in good company, and still deserve respect regardless of which side of the fence you fall.

http://matthewmachuga.com/blog/2015/activerecord-and-the-beauty-lost-in-translation.html

Read more

GraphQL: A data query language

When we built Facebook's mobile applications, we needed a data-fetching API powerful enough to describe all of Facebook, yet simple enough to be easy to learn and use by our product developers. We developed GraphQL three years ago to fill this need. Today it powers hundreds of billions of API calls a day. This year we've begun the process of open-sourcing GraphQL by drafting a specification, releasing a reference implementation, and forming a community around it at graphql.org.
https://code.facebook.com/posts/1691455094417024/graphql-a-data-query-language/

There's already a package to use GraphQL with Laravel.

Read more

A package to add roles and permissions to Laravel original

by Freek Van der Herten – 1 minute read

With the release of Laravel 5.1.1 last week the framework gained some nice Authorization features. It provides an easy way to define abilities (aka permissions). Checking if a user has certain abilities is very simple as well. The code powering authorization is a thing of beauty. If you're a…

Read more

Dependency injection with League's new Container

Jens Segers explains how to use PHP League's shiny new version of Container. The usage of ContainerInterface seems interesting:

League's container now implements the `ContainerInterface`, which is defined by the Container Interoperability group. This is really great as there are a few projects and frameworks which support this interface. For example, the Slim 3 micro framework already allows you to choose your own container flavour, as long as it implements the interface.
Read the full article at Jens' blog.

The League's Container seems like a nice alternative to PHP DI that I have been using.

Read more

Hacking the flow state

Often, when I’m able to slip into a state of flow while coding, I will produce more in a single afternoon than I could in several days of non-flow. Yet this is often an elusive state to obtain. Luckily, research dedicated to this topic in recent decades offers some help. Here we’ll look into both the stages of flow and how to obtain the prerequisites for flow, making it possible in the first place.

https://medium.com/brigade-engineering/hacking-the-flow-state-b2451d0bf7ba

Read more