Posts About Laravel
Laravel is a powerful PHP framework that simplifies web development with its elegant syntax and comprehensive toolkit. It streamlines tasks like routing, authentication, and caching, making it ideal for both simple and complex applications.
Reporting Exceptions in Laravel
Reporting is the half of exception handling the user never sees. When something goes wrong, you want a record of it so you can find out what h...
Switching Queue Drivers in Laravel Without Downtime
Each queue driver has its strengths, and one day you may want to move from one to another, say from the database driver to redis as you grow....
Log In with Either Username or Email in Laravel
A nice touch for users is one login field that accepts either their username or their email, instead of forcing them to remember which they si...
Customising the Password Reset Email in Laravel
Laravel sends a perfectly fine password reset email out of the box, but it is plain and unbranded. When a reader asked how to replace it with...
Removing Jobs of a Specific Type From a Laravel Queue
Here is a real incident. A pull request was merged by mistake and pushed one particular job to the queue more than a hundred thousand times. T...
Creating a One to Many Relationship in Laravel
A one to many relationship, also called a has many, is when one row in a parent table matches many rows in a child table. This is the relation...
Modern Laravel Queue Features Worth Knowing
The Laravel queue system grew a set of features that, taken together, make it genuinely production grade. Here is a tour of the ones worth hav...
Fixing the "Specified key was too long" Migration Error in Laravel
If you have hit this error while running migrations, here is the quick fix and the reason behind it. Why it happens Laravel uses the utf8mb4 c...
Creating and Using Query Scopes in Laravel
A query scope is a reusable piece of a query that you keep on the model. Instead of repeating the same where everywhere, you give it a name an...
Creating Foreign Key References in a Laravel Migration
A foreign key is how the database itself enforces that a row in one table points at a real row in another. Laravel makes adding one short, and...
Avoiding Lock Timeouts When Dispatching Large Job Batches
Batches are great until you dispatch a really big one. Push thousands of jobs into a single batch and you can deadlock your own queue, with wo...
Handling API Rate Limits in Queued Jobs
If your jobs call a third party API, sooner or later you will hit its rate limit and start getting 429 Too Many Requests. Hammering the API ha...
Using Aggregate Functions with Eloquent in Laravel
Sometimes you do not want the records themselves, you want a number about them. How many active products, the highest price, the average ratin...
Laravel Queue Configuration Keys Explained
A few queue settings trip up nearly everyone, mostly because two of them look like they do the same thing and actually do not. Here is each on...
File Uploads and Storage in Laravel
Laravel's Storage API lets you handle files without caring where they actually live. The same code works whether the files are on the local di...
Pointing Your Domain at the Laravel public Folder
A Laravel project has one folder that is meant to face the web: public. Everything else, your code, your .env, your config, sits above it and...
Working with Large Result Sets in Laravel
The moment you call get or all on a big table, Laravel loads every matching row into memory and builds a model for each one. On a few hundred...
Job Has Been Attempted Too Many Times or Run Too Long
You open your logs or failed_jobs table and find a job marked failed with MaxAttemptsExceededException and the message "Job has been atte...
How Notification Channels Work in Laravel
When a notification is sent, each channel listed in via() has to be turned into a real object that knows how to deliver the message, and the m...
Extending Laravel with Macros
Many of Laravel's core classes are "macroable", which means you can bolt your own methods onto them at runtime without touching the...