You're making some very good points, but I disagree with the wording of this statement:
Larvel comes with Eager loading (ORM) so use it , avoid writing your own raw query.
Avoid writing your own raw query unless you know what you're doing. Sometimes it's needed to write raw queries but when you do so ensure you don't create an SQL Injection vulnerability.
A use case for this is using the Haversine formula to calculate distance between coordinates.
Sometimes doing it yourself is just what you need.
Also on the topic of PurgeCSS you fail to mention that if you're using dynamically built class names PurgeCSS will not work as you'd expect.
As PurgeCSS checks things statically, classes built like so will not be safe unless you put it in the safelist option:
// Assuming status is one of the following: success, error, info<divclass="{{ 'alert-'.$status }}">{{$someAlertMessage}}</div>
PurgeCSS will not understand that alert-success, alert-error and alert-info are in use, thus they will be purged in a production build.
I wrote a scope for the haversine formula which enablede to keep using the ORM π
If you're really looking at improving performance of a Laravel application you have two options in 2021:
Laravel Vapor
Laravel Octaine
Serverless, or a long running process. There are micro optimization a you can do with a Laravel app, but none that make a huge difference straight away.
You're making some very good points, but I disagree with the wording of this statement:
Avoid writing your own raw query unless you know what you're doing. Sometimes it's needed to write raw queries but when you do so ensure you don't create an SQL Injection vulnerability.
A use case for this is using the Haversine formula to calculate distance between coordinates.
Sometimes doing it yourself is just what you need.
Also on the topic of PurgeCSS you fail to mention that if you're using dynamically built class names PurgeCSS will not work as you'd expect.
As PurgeCSS checks things statically, classes built like so will not be safe unless you put it in the
safelist
option:PurgeCSS will not understand that
alert-success
,alert-error
andalert-info
are in use, thus they will be purged in a production build.Instead, you'd use something like this:
I wrote a scope for the haversine formula which enablede to keep using the ORM π
If you're really looking at improving performance of a Laravel application you have two options in 2021:
Serverless, or a long running process. There are micro optimization a you can do with a Laravel app, but none that make a huge difference straight away.
@rvxlab you are right brother πβοΈ I couldn't explain it briefly , but u did βΊοΈπβοΈ