Laravel In development
The nabd/laravel package: adds the browser script and, optionally, server error types.
Not available yet. These examples show the planned API; package and function names may change before the first release.
Install
composer require nabd/laravel
php artisan vendor:publish --tag=nabd-configOnce published. Publishing the config file is optional.
Setup
NABD_PUBLIC_KEY=nb_pub_…
NABD_APP_NAME="My Portal"
NABD_CONSENT_REQUIRED=trueThe public key only. The package does not need the secret key, and if it is put in place of the public one it is not printed in the page.
Browser
@nabdScripts
</body>window.Nabd.setConsent(true);Livewire and Inertia navigation is picked up from History API changes. With Vite::useCspNonce() both tags get the nonce.
Screen names
NABD_SCREEN_NAMES | Name | When |
|---|---|---|
url (default) | From the page URL with identifiers turned into :id | Livewire and Inertia |
route | The route pattern /customers/:name | Every navigation is a full page load |
If your URLs contain names (/customers/ahmed-ali) and the app does not reload the page on every navigation, name the screens yourself.
Support chat: NABD_MESSAGES=true (details).
Server errors (optional)
NABD_SERVER_ERRORS=trueWhen a fetch or XMLHttpRequest request returns a 5xx from an exception, the response carries an X-Nabd-Error header with the exception type name and a fingerprint of its location, and the browser records them on the same session and screen instead of the generic error (one event). No message, stack or file paths.
- The type name (for example
QueryException) becomes visible to anyone who sees the response. Leave it off if that is not acceptable. - Errors in background jobs and commands, and error pages opened as a full navigation, are not recorded.
- API on another domain: the header is added to
Access-Control-Expose-Headers. - Slow requests are measured in the browser, so there is no server setting for them.