The official Treblle SDK for JavaScript frameworks including Laravel. Seamlessly integrate Treblle to manage communication with your dashboard, send errors, and secure sensitive data.
Treblle with Laravel
Features
- All Treblle features
- Supports Laravel Vapor and Laravel Octane
Requirements
- PHP 8+
- Laravel 10, 11, 12
Dependencies
Installation
Install Treblle for Laravel via Composer by running the following command in your terminal:
composer require treblle/treblle-laravelCreate an account, login to your existing account, create a new api and get all the .ENV keys you need to start using Treblle.
You can also visit our website https://app.treblle.com and create a FREE account to get your API key and SDK token. Once you have them, simply add them to your .ENV file:
TREBLLE_API_KEY=YOUR_API_KEY
TREBLLE_SDK_TOKEN=YOUR_SDK_TOKENEnabling Treblle on your API
Note
In case you want to temporarily disable observability, you can do so by setting env as TREBLLE_ENABLE=false
Tip
We’ve created a comprehensive, hands-on guide to building your Laravel API. Check out our Laravel API Course for a detailed, step-by-step walkthrough.
Upgrading from v5.x to v6.0
Version 6.0 introduces breaking changes to environment variable names. If you’re upgrading from v5.x:
1. Update your .env file:
# Old configuration (v5.x)
TREBLLE_API_KEY=your_old_api_key
TREBLLE_SDK_TOKEN=your_old_SDK_TOKEN
# New configuration (v6.0)
TREBLLE_SDK_TOKEN=your_old_api_key
TREBLLE_API_KEY=your_old_SDK_TOKEN2. If using dynamic middleware parameters, update route definitions:
// Old (v5.x)
Route::middleware(['treblle:sdk-token-1'])->group(function () { ... });
// New (v6.0)
Route::middleware(['treblle:api-key-1'])->group(function () { ... });3. Clear caches:
php artisan config:clear
php artisan cache:clearConfiguration options
You can configure Treblle using just .env variables:
TREBLLE_IGNORED_ENV=local,dev,testDefine which environments Treblle should NOT LOG at all. By default, Treblle will log all environments except local, dev and test. If you want to change that you can define your own ignored environments by using a comma separated list, or allow all environments by leaving the value empty.
Masked fields
Treblle masks sensitive information from both the request and response data as well as the request headers data before it even leaves your server. The following parameters are automatically masked: password, pwd, secret, password_confirmation, cc, card_number, ccv, ssn, credit_score.
You can customize this list by editing your configuration file.
Open file config/treblle.php and tweak the masked fields:
return [
// ...
/*
* Define which fields should be masked before leaving the server
*/
'masked_fields' => [
'password',
'pwd',
'secret',
'password_confirmation',
'cc',
'card_number',
'ccv',
'ssn',
'credit_score',
'api_key',
],
];