Appearance
Laravel Nova conventions
INFO
This document is not finished yet.
Principles
There are a few principles we use to make almost any decision regarding Nova conventions:
- Do not expose code needed by Nova to the outside world (outside
App\NovaandApp\{Module}\Novanamespaces). - As usually, do not use magic when possible.
- Reusable components should be extracted to separate composer packages (published on Packagist or hosted within the app repository in a
packagessubdirectory).
Minimize the number of Nova packages
Minimize usages of Nova packages. Reasons:
- Updatability: Nova packages are often not very stable on Nova updates and often have bad community support. They can block Nova updated (even patch versions)
- Performance: JS and CSS assets of all Nova packages loaded on every page load, and these assets are served by webserver-PHP-webserver chain (not by web-server directly and thus produces more load to the server), see
\Laravel\Nova\Http\Controllers\ScriptController::class.
For these reasons, it’s better to avoid using Nova packages and always use native functionality when it’s possible.
Resources
have a question to cover here? — Write it here!
Use translations field help text
Using code like ->help(__('nova-resource-name.help.fields.field_name')) helps non-developers to improve help texts.
Actions
have a question to cover here? — Write it here!
Nova Action should wrap domain action
If Nova action does a normal domain operation (not fixing some specific issue), it should wrap domain action class.
Use Action classname suffix
This improves DX when you need to run find and replace on actions only (PHPStorm's find&replace dialog has a filter).
Authorization
Do not use Model Policies for Nova Actions (see principles).
Filters
... have a question to cover here? — Write it here!
Metrics
... have a question to cover here? — Write it here!
🦄