Treblle with PHP
Requirements
- PHP 7.4+
Dependencies
Installation
You can install Treblle for PHP via Composer. Simply run the following command:
Getting started
Next, create a FREE account on treblle.com to get an API key and Project ID. After you have those simply initialize Treblle in your API code like so:
That’s it. Your API requests and responses are now being sent to your Treblle project. Just by adding that line of code you get features like: auto-documentation, real-time request/response monitoring, error tracking and so much more.
Configuration options
Debug mode
The third parameter sent to TreblleFactory::create
factory method is a boolean flag indicating whether we want to use
Treblle in debug mode. Enabling debug mode is helpful when you want to understand what’s happening under-the-hood and
allow Treblle errors to bubble up.
Masking sensitive information
Treblle masks sensitive information from the request parameters 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 extend this
list by providing your own custom keywords by doing the following:
Overriding HTTP client and Treblle endpoint URL
The fifth parameter passed to TreblleFactory::create
factory method is an array of config options allowing you to
override some components of Treblle.
The following values are supported:
client
- an instance of Guzzle client configured to behave as you want (e.g. controling the timeout or other aspects)url
- Treblle API endpoint URL you want to use