
My Laravel project is in part a headless CMS - this means it has and API that gets called by a frontend system - with around 10 API requests per page view.
We can cache some of that - but sometimes caches are empty and the site still has to be responsive.
The meant I needed to optimise my Laravel site and after a few experiments I found that using [Laravel Octane]](https://laravel.com/docs/12.x/octane) with FrankenPHP gave me the performance boost I needed without needing any significant code change.
Read more ...
I want to use a distributed cache in my Laravel Application to make the app more responsive and reduce database load.
I’m not sure whether to use Memcache or Redis
Read more ...
This is a silly one.
I wanted to run Laravel in dev mode but using the compiled js and scss from npm run build
via vitejs.
This usually works
but for some reason Laravel was trying to serve js/css from http://localhost:5173/@vite/client
a service I usually run - but I wanted to test the build stuff.
The solution is really simple but not well documented.
Read more ...Laravel Validation supports rules forcing unique values - but exceptions are usually needed.
For example if you have articles on a site where each has a slug that has to be unique - when you update the article it has to possible to save the article using the slug it already has.
https://laravel.com/docs/10.x/validation#rule-unique

Read more ...For some reason I always seem to struggle getting code coverage reports picked up by SonarQube - the documentation isn’t bad but it seems to take me a while to find the right incantation .
I wanted both my PhpUnit tests and Javascript unit tests for my laravel project to generate coverage reports and import this to SonarQube.
Read more ...
The Laravel Docs have a section Constraining Eager Loads
Which hides a lot of power available to you while loading relationships.
It can be used for more than just “constraints”
If you want to sort your relations by a specific fields, add a count of a nested relationship, or in other ways add to teh query - this is where you can do it.
Read more ...
I am working on a project that makes use React within Laravel.
I didn’t find much support for setting up React tests.
So here are som notes on how I got it working.
Read more ...
I needed to send password reset emails from Laravel with additional data so that depending on how the password reset is triggered the email content varies.
Read more ...
You may not need this, if you can manage multiple types of user via roles and permissions it will be much the simpler route to follow.
In my case I wanted user with different: properties, relationships, routes, password rules, timeouts, and more.
It was worth the pain of setting up two authenticatable models.
Laravel is very flexible and well documented, but the further you stray from what most people do - the less obvious it is and a few of these steps took me a while to figure out.
Read more ...
InertiaJs does a great job of helping me build React apps on Laravel. The form help does a great job - especially with displaying validation messages.
But I couldn’t figure out how to change data and save the form in one action.
Read more ...