Master Laravel with hand-curated daily tips
Laravel documentation is top-notch, but it's impossible to cover everything. Mastering Laravel is not just solving problems when you're stuck - it's also about becoming the best Artisan and programmer you can be.
We're excited to share a daily email with you that you can read in less than 2 minutes. Oh, and if daily is too often - don't worry - you can opt into weekly digests instead.
I've been subscribed to this newsletter for less than a week, and I already received some advice that I was able to instantly implement into my daily work.Samuel Pedraza
Daily Tips Archive
We've been cranking out tips for a while now. Can you believe there are 165 of them?! Keep on scrolling to see what you may have missed below.
Understanding how caching works in GitHub Actions
Are you really going to need that abstraction?
Forcing all API requests to accept JSON
How to use Pusher with private encrypted channels
An easy way to test UUIDs
Understanding the order of authorization and model binding
A trick for geolocating US postal codes
How to step debug a queued job
Cleaning up deprecated warnings during a database migration
Monitoring progress of a big database import
A good rule for when to create a factory state
Should you change app code for a test?
Loading a SQL backup without altering your configuration
Why I always add a primary key to many-to-many tables
Make sure your listeners are wired up
How to set CORS headers for built assets
Something to know if serving scripts for other sites
Loading relationships inside a queued job
A better way to drop a unique index
Why pagination sometimes has overlapping pages
Sharing redirect logic between controller actions
Prefer a little bit more meat with your tips?
You're in luck! This ebook contains tips and tricks that are quick and easy to apply but make a noticeable improvement in any Laravel app. Dig in a little bit deeper with larger code samples and deeper explanations.
February, 2024
What is the point of design patterns?
Manual testing still has its place
Ignoring files per environment with Docker
Quickly viewing test file structure
Picking a good test value
Pay attention to analytics
Consistent test organization
How we use migrations during early product development
Simple rules for writing authorization logic
One place I avoid constructor property promotion
Move that logic out of your view
Alpha validation might not be doing what you think
Avoid changing your code purely for a test
Get better auto-complete from your factories
Watch out for this when testing Artisan commands
A clean approach to testing events and listeners
Another reason I like fillable instead of guarded
A safer way to check model strictness in production
Why does Laravel offer a max password length validation rule?
Composer scripts and Valet isolate
Is it worth switching to another tool?
January, 2024
Being explicit when something should not queue
Absolute paths and the Vite asset helper
Don't become numb to pain in your project
Why might you want to forget a route parameter?
Inspecting files in a Docker container
Considerations when cleaning up a big table
A measured approach to using Larastan
How to test that a model wasn't changed
Running HTTP requests right inside your editor
How we use seeders in our application
Another nice feature for local pull request review
Eager loading, but only if you really need to
Route binding with two different models
Stop using $request->get()
Don't reinvent features that Laravel already has
Vite Hot Module Replacement and setInterval
What is the difference between boot and register in service providers
Even GitHub comments have version control
Failing tests give you confidence
Don't just get mad at some tech, dig in and learn
Use factories to make your tests more readable
One situation where it is useful to make more than one request in a test
Using factories with more than one relationship
December, 2023
Redirect routes match all HTTP verbs
Routes resolve differently when cached
The benefits of caching in CI
Don't cache routes or views locally
View source always makes a new request
How clear coding rules can free up your team
Making a case for consistency
Why the nullable validation rule is useful
Why we don't use SQLite for tests
When it might be ok to use a mixed type
Using writing to think through a problem
Are you writing script definitions in Composer?
Why we don't use return types on controller actions
How to route based on the requested domain
Keep your testing database separate from development
Don't rely on key ordering with MySQL JSON values
Different approaches to upgrading to a new major Laravel version
Be consistent with composer scripts in CI
Why we like minimal seeders for tests
You don't need to manually run seeders in your tests
A surprising issue with the Auth user and tests
November, 2023
Lazy loading protection does not catch all N+1 queries
Should you be able to override coding standards locally?
A simple approach to localization using middleware
How to rate limit by IP behind a Cloudflare proxy
Don't take it personal if your contribution is rejected
Maybe you don't need to write code this time
How to reference a PHP CodeSniffer ruleset in EasyCodingStandard
How does LetsEncrypt work behind Cloudflare?
Considerations when eager loading resource collections
The right way to fix double encoding in Blade components
Version untracked files with PhpStorm
Enforcing Horizon auth in local
Cloudflare, Laravel, and TLS
A good rule around "down" migrations
Use the right tool for the job
Should you manage roles and permissions with a UI?
Understanding how Laravel sessions work
Using workarounds without creating a mess
Dealing with messy JSON
The value of a quick code demo
Don't get defensive during code review
How to assert a Laravel job is delayed
October, 2023
Ever need a different git setting per repo?
Keep your code consistent
How to get rid of HEIC files in your app
The changing value of books throughout your career
Actually read the whole error message
How much detail should you include in error messages?
Is it time to abstract this?
How do you test middleware?
Document before automating
A simple way to avoid multiple lookups within a request
Joins in Eloquent? How?
Ship something every day
Is sleep in a test always bad?
Some reasons to write a down method in your migrations
Use custom Mockery matchers for better Laravel assertions
What does INT(11) mean in MySQL?
How do you insert a new column at the beginning of a MySQL table?
Be careful ordering columns in a migration
Applying a class to a Markdown link
Don't forget to pin PECL extensions
How to make the AWS SDK much smaller
Do you really need to install that SDK?
September, 2023
Cache Larastan results in Github Actions
Managing a micro-manager
Drop unneeded steps in CI
Keep your Laravel CI pipeline running fast
Knowing when to keep it simple
Should we write tests for this one-time command?
A good use case for the Eloquent sole() method
The benefit of one-time commands
Do we really need to build this feature?
Easily find specific code usages in PhpStorm without regex
Understanding how Laravel view assertions work internally
Local history in PHPStorm
Be careful when using assertViewHas with null
When to pull in top-level dependencies
Use GitHub issue templates to save time
What if every Composer package had a fee?
How to override PHPStorm file types
When might you render a Blade template inline?
How to make a bug fix way more valuable
Don't explicitly install dependencies if you don't need to
Take time to make things better
August, 2023
Tools should work for you, not boss you around
Try not to make things worse
Are fast queries always good?
Clean up dead git branch references automatically
A scenario using events and observers together
When should you use events and observers?
How do you know if something is slow in production?
Something slow? It's probably the database.
How do you know something is slow?
What if you need a value that's random AND unique?
Harness that post-conference excitement
Learn to love code review
Find out what's slow BEFORE you deploy to prod
Sometimes Eloquent can make a query slower
Level up your Laravel skills!
Each 2-minute email has real-world advice you can use.