Laravel

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...

5 mins read

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....

3 mins read

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...

2 mins read

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...

1 mins read

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...

3 mins read

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...

2 mins read

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...

3 mins read

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...

2 mins read

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...

2 mins read

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...

2 mins read

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...

3 mins read

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...

3 mins read

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...

2 mins read

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...

4 mins read

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...

2 mins read

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...

2 mins read

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...

2 mins read

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...

3 mins read

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...

3 mins read

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...

2 mins read