Treblle with Laravel
Features
- All Treblle features
- Supports Laravel Vapor and Laravel Octane
Requirements
- PHP 8+
- Laravel 10
Dependencies
Installation
Install Treblle for Laravel via Composer by running the following command in your terminal:
Getting started
You can get started with Treblle directly from your Artisan console. Just type in the following command in your terminal:
The command guides you through a setup process and allows you to create 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 treblle.com and create a free account to get your API key and Project ID. Once
you have both your API key and project ID, simply add them to your .env
file:
Enabling Treblle on your API
Your first step should be to register Treblle into your in your middleware aliases in app/Http/Kernel.php
:
Open the routes/api.php and add the Treblle middleware to either a route group like so:
or to an individual route like so:
Youβre all set. Next time someone makes a request to your API you will see it in real-time on your Treblle dashboard alongside other features like: auto-generated documentation, error tracking, analytics and API quality scoring.
Laravel 11
If you are using Laravel 11, then all you need to do is register the middleware inside bootstrap/app.php
like so:
Or, alternatively you can inline this inside your routes:
Configuration options
You can configure Treblle using just .env
variables:
Define 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. If you did not published your configuration file, run this command first:
This will create a file at config/treblle.php
. Then, open this file and tweak the masked fields: