Treblle with Laravel
Features
Section titled “Features”- All Treblle features
- Supports Laravel Vapor and Laravel Octane
Requirements
Section titled “Requirements”- PHP 8+
- Laravel 10, 11, 12
Dependencies
Section titled “Dependencies”Installation
Section titled “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 project 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_KEYTREBLLE_SDK_TOKEN=YOUR_SDK_TOKENEnabling Treblle on your API
Section titled “Enabling Treblle on your API”NOTE: In case you want to temporarily disable observability, you can do so by setting env as TREBLLE_ENABLE=false
Upgrading from v5.x to v6.0
Section titled “Upgrading from v5.x to v6.0”Version 6.0 introduces breaking changes to environment variable names. If you’re upgrading from v5.x:
-
Update your
.envfile:Terminal window # Old configuration (v5.x)TREBLLE_API_KEY=your_old_api_keyTREBLLE_PROJECT_ID=your_old_project_id# New configuration (v6.0)TREBLLE_SDK_TOKEN=your_old_api_keyTREBLLE_API_KEY=your_old_project_id -
If using dynamic middleware parameters, update route definitions:
// Old (v5.x)Route::middleware(['treblle:project-id-1'])->group(function () { ... });// New (v6.0)Route::middleware(['treblle:api-key-1'])->group(function () { ... }); -
Clear caches:
Terminal window php artisan config:clearphp artisan cache:clear
Configuration options
Section titled “Configuration 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
Section titled “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', ],];