Don't rely on key ordering with MySQL JSON values
This behavior caught me by surprise
Different approaches to upgrading to a new major Laravel version
And we explain the pros and cons of each
Be consistent with composer scripts in CI
Keep it simple and save yourself some trouble
Why we like minimal seeders for tests
Getting this right will make your tests so much easier to maintain
You don't need to manually run seeders in your tests
Laravel is constantly making things nicer
A surprising issue with the Auth user and tests
Knowing how this works helps you avoid false failures in your tests
Lazy loading protection does not catch all N+1 queries
I discovered this one the hard way
Should you be able to override coding standards locally?
And why am I even asking this question?
A simple approach to localization using middleware
We used this on a recent project and it worked great.
How to rate limit by IP behind a Cloudflare proxy
If you don't do this, your app could actually start blocking Cloudflare traffic.
Don't take it personal if your contribution is rejected
You had a good idea and submitted it, but then the project rejects it. Now what?
Maybe you don't need to write code this time
And using a no-code tool may even give you more empathy for users of your app
How to reference a PHP CodeSniffer ruleset in EasyCodingStandard
This simple addition can make it much easier to migrate between tools
How does LetsEncrypt work behind Cloudflare?
If we use a proxy like Cloudflare, will it impact our ability to issue LetsEncrypt certificates?
Considerations when eager loading resource collections
Check out a subtle bug that avoided notice for a while, and how tests eventually helped us.
The right way to fix double encoding in Blade components
There is a lot of bad advice out there on this topic. Here's a better approach.
Version untracked files with PhpStorm
Another very handy use for PhpStorm's Local History feature
Enforcing Horizon auth in local
Is this overkill? Or does it give you more confidence in your application?
Cloudflare, Laravel, and TLS
Double check this setting to save yourself some trouble
A good rule around "down" migrations
Some would say don't bother to write "down" migrations. I argue that if you do, you should follow this rule.
Use the right tool for the job
You can still have your favorite, but it's good to see what else is out there
Should you manage roles and permissions with a UI?
It's tempting to let non-developers manage this data, but is it a good idea?
Understanding how Laravel sessions work
If we don't know how something works, it's more confusing when things behave differently than expected.
Using workarounds without creating a mess
Sometimes a workaround is unavoidable, but how can you avoid them from piling up technical debt?
Dealing with messy JSON
Sometimes API do unspeakable things and we have to work around it in our app
The value of a quick code demo
Sometimes it's more effective to show than tell
Don't get defensive during code review
Sometimes even a small observation can lead to a big improvement
How to assert a Laravel job is delayed
I've seen a lot of convoluted approaches to this, here's a drop-dead simple way to do it.
Ever need a different git setting per repo?
Maybe you have one git account for work, and one for open source. How do you make sure the right author is used in each repo?
Keep your code consistent
Ever find 5 different ways of doing something in a single codebase? Here's an approach to minimize that.
How to get rid of HEIC files in your app
And it makes your app easier to use for non-iPhone users too
The changing value of books throughout your career
Perhaps that book you thought was useless 5 years ago is exactly what you need today.
Actually read the whole error message
This seems really simple and obvious, but I've been burned in the past not doing this myself.
How much detail should you include in error messages?
Error messages are part of user experience.
Is it time to abstract this?
You spot two things in your app that are mostly the same. Is that an automatic refactor?
How do you test middleware?
Middleware can be a tricky thing to test. Here's what I did in a recent project.
Document before automating
As devs, sometimes we rush to coding a solution. But there's an important step that should come first.
A simple way to avoid multiple lookups within a request
Traditional caching comes with its own set of complexities. Here's a simple way to use basic PHP instead.
Joins in Eloquent? How?
Sometimes you need a join for performance or sorting by relations. Here's a way to do that without giving up Eloquent.
Ship something every day
There's value in shipping something, anything, at least once a day, even on a bigger feature.
Is sleep in a test always bad?
You might think adding sleep to a test is a dirty hack, but it's not always a bad thing.
Some reasons to write a down method in your migrations
And it's probably not the reason you think.
Use custom Mockery matchers for better Laravel assertions
Clean up your tests, especially when passing models as arguments
What does INT(11) mean in MySQL?
Here's a hint: it has nothing to do with length
How do you insert a new column at the beginning of a MySQL table?
And more importantly, why would you want to?
Be careful ordering columns in a migration
Laravel migrations let us insert a column in a specific position in a table, but it's not always a good idea.
Applying a class to a Markdown link
Ever wish you could add a CSS class to a Markdown link? Here's how I did it.
Don't forget to pin PECL extensions
We pin Composer packages and PHP versions, but what about PECL extensions?
How to make the AWS SDK much smaller
Only need a small portion of the AWS SDK, and wish you could make it a lot smaller?
Do you really need to install that SDK?
If you're integrating with a third-party API, you may not need to bring in a giant SDK.
Cache Larastan results in Github Actions
Larastan is a great tool, but it can slow down your CI pipeline. Here's how to cache the results to make each run faster.
Managing a micro-manager
It's frustrating to have a client or co-worker attempt to micro-manage you. We share some tips on how to make the working relationship better.
Drop unneeded steps in CI
This might seem pretty obvious, but it's easy to forget to remove steps from your CI pipeline when they are no longer needed.
Keep your Laravel CI pipeline running fast
CI pipelines tend to get slower over time, the more we add to them, and the bigger our project grows. Keeping an eye on this is important.
Knowing when to keep it simple
We take pride in building things "the right way", but there is a balance to strike with simplicity.
Should we write tests for this one-time command?
I'm a huge proponent of writing tests, but is there ever a valid time to skip them?
A good use case for the Eloquent sole() method
The sole() method has been around for a while, but I don't use it very much. Here's one place I found it useful.
The benefit of one-time commands
Is there any reason to build a Laravel command you only plan to use one time? Let's consider a few benefits.
Do we really need to build this feature?
Before diving into the code and cranking out a feature, sometimes it's useful to consider if we really need to build it at all.
Easily find specific code usages in PhpStorm without regex
Regexes in search logic are powerful, but this tip will supercharge your code searching without needing to get too fancy.
Understanding how Laravel view assertions work internally
No one likes a passing test when the actual logic is wrong. Here's how to make sure your view assertions are actually testing what you think they are.
Local history in PHPStorm
If you already have git, why would you use the local history feature in PHPStorm?
Be careful when using assertViewHas with null
Laravel's assertViewHas method doesn't work for null values. Here's how to test for them.
When to pull in top-level dependencies
If Laravel already requires a package, is there ever a reason to install it into your project directly?
Use GitHub issue templates to save time
Having a template not only makes issue creation easier, but also more consistent.
What if every Composer package had a fee?
An interesting thought experiment that might influence how many packages you pull into your project.
How to override PHPStorm file types
PHPStorm allows you to override the file type, giving you different syntax highlighting and auto-complete prompts.
When might you render a Blade template inline?
This isn't a feature I reach for frequently, but it's good to know it exists. Here is one use case where we found it quite handy.
How to make a bug fix way more valuable
Fixing bugs is important, but by taking just a little more time you can make your app much more resilient
Don't explicitly install dependencies if you don't need to
Pay attention to the dependencies Laravel or other packages are already bringing in. You may be pinning them to an older version without realizing it.
Take time to make things better
Look for opportunities to make things just a little bit nicer than you found them.
Tools should work for you, not boss you around
Ever have a day where you're "fixing the squiggles" in your editor and feel like the code got worse? Let's talk about how to avoid that.
Try not to make things worse
You know those parts of a codebase that feel "not great"? Be mindful to not further entrench those bad decisions.
Are fast queries always good?
I mean, yeah! Right? Well, there's more to the story...
Clean up dead git branch references automatically
When you merge a branch in GitHub, the reference to it is still in your local repo. How can you clean those up automatically?
A scenario using events and observers together
Sometimes it's useful to pair events and observers together. Let's look at one real-world example.
When should you use events and observers?
Laravel events and observers seem to do very similar things. So when would you use one over the other?
How do you know if something is slow in production?
The tools we used for finding slow code in development are not suitable for production. So how can we find slow code there?
Something slow? It's probably the database.
The absolute number one cause of slow code is the database. Laravel makes fixing some of the common issues very easy.
How do you know something is slow?
The first step in making your app faster is knowing what is slow. How do you figure that out?
What if you need a value that's random AND unique?
Sometimes we need random data that is ALSO unique. How can you generate that in Laravel?
Harness that post-conference excitement
New features! New packages! New techniques! How can we harness that excitement when we get back to work a conference?
Learn to love code review
Code review feedback might make us feel defensive, but if you approach it with the right attitude it can become something you value.
Find out what's slow BEFORE you deploy to prod
The earlier you find an issue, the better! How can we improve our chances of finding slow code before it reaches production?
Sometimes Eloquent can make a query slower
Eloquent improves developer efficiency, but in some cases it can make a query less efficient. Let's look at one example and how to fix it.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
Level up your Laravel skills!
Each 2-minute email has real-world advice you can use.