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.
The Database Queue Driver Is Production Ready
For years the advice was clear: never run the database queue driver in production, use Redis. That advice is out of date. Modern databases fix...
Laravel Database Connection and Configuration
Laravel keeps database setup simple. You rarely touch raw connection code. Instead you fill in a few values, and Eloquent and the query builde...
"Serialization of 'Closure' Is Not Allowed" in Laravel
This one fails immediately, in the request, before the job is ever queued: Others in the same family show up as Serialization of 'PDO' is not...
List All Your Routes in Laravel
Sometimes you just need to see every route in your app, with its method, URI and the controller action behind it. Years ago you might have wri...
Ensuring Horizon Terminates Gracefully
One of Horizon's nicest features is graceful shutdown: when told to stop, it waits for any in-flight jobs to finish before terminating its wor...
Creating a One to One Relationship in Laravel
A one to one relationship means one row in a table matches exactly one row in another table. You do not reach for it often, because if two tab...
Laravel Database Per Tenant: On the Fly Connections for a Multi Tenant App
Giving every tenant their own database is one of those things that sounds hard until you see how Laravel actually wires up a connection. Once...
Introduction to Redis with Laravel
Redis is a storage server that keeps your data in memory, which makes reading and writing extremely fast. It can also save that data to disk n...
ModelNotFoundException in Queued Jobs
A job blows up in failed_jobs with a message like this: Listing 41 definitely existed when you dispatched the job. It does not exist now. Noth...
Force HTTPS and a Canonical Domain in Laravel
For SEO and consistency you want every visitor on one canonical address: HTTPS, and one of www or the bare domain, not both. Serving the same...
Accessing Route Parameters in Laravel Middleware
Middleware wraps a request: it runs code before or after your controller. Sometimes that code needs to know a value from the URL, like the {us...
How Laravel Prepares a Job for the Queue
When you dispatch a job, it does not run there and then. It gets turned into a small record and stored, in MySQL, Redis, or SQS, until a worke...
Speeding Up Laravel on a Production Server
A fresh Laravel deploy can feel sluggish, and the fix is usually not your code. It is that production is still running with development settin...
Persisting Redis Data on Disk: Snapshots vs AOF
Redis keeps your data in memory, which is exactly why it is fast and also why a crash can wipe everything in an instant. For some uses that is...
Dispatching Unique Jobs to Laravel Queues
Here is a common need. Every time a product is updated you dispatch a job to rebuild the search index. If ten products are edited in a minute,...
When Queueing a Job Makes Things Worse
Once you have a queue running, everything starts to look like a job. Slow endpoint? Queue it. Sending an email? Queue it. Updating a counter?...
Database Transactions in Laravel, and the afterCommit Trap
A database transaction groups several queries into one all or nothing unit. Either every query succeeds and the changes stick, or one of them...
Prevent Your Queued Jobs From Running Twice
You notice the same job ran twice. The email went out twice, the charge happened twice, and you are sure you dispatched it once. Before suspec...
To Use Laravel Vapor or Not?
Vapor is great, but it is not for every project. Rather than hype it, here are the objections people actually raise, answered honestly, so you...
Your Jobs Are Running Instantly Instead of Queuing
You moved a slow thumbnail job onto the queue, deployed, and the endpoint is exactly as slow as it was before. There are no rows in the jobs t...