Skip to content

Configuration Reference

Leakless is configured via the TheMattos\Leakless\Config object in vanilla PHP, or via .env / config/leakless.php in Laravel Octane.


1. Vanilla PHP Configuration

Instantiate the Config object with your desired options:

php
use TheMattos\Leakless\Config;
use TheMattos\Leakless\Leakless;

$config = new Config(
    enabled: true,             // Enable or disable Leakless
    maxRssMb: 256.0,           // Maximum Linux kernel RSS memory threshold in MB
    maxRequests: 1000,         // Maximum requests handled before worker recycling
    checkTransactions: true,   // Detect and roll back uncommitted PDO transactions
    rollbackState: true,       // Restore timezone, output buffers, and error levels
    logViolations: true,       // Emit diagnostic logs when anomalies are caught
);

$leakless = new Leakless($config);

2. Laravel Octane Configuration

In Laravel applications, configure settings directly in .env:

ini
LEAKLESS_ENABLED=true
LEAKLESS_MAX_RSS_MB=256
LEAKLESS_MAX_REQUESTS=1000
LEAKLESS_CHECK_TRANSACTIONS=true
LEAKLESS_ROLLBACK_STATE=true
LEAKLESS_LOG_VIOLATIONS=true

Or publish config/leakless.php:

bash
php artisan vendor:publish --tag="leakless-config"

3. Options Reference

OptionEnvironment VariableDefaultDescription
enabledLEAKLESS_ENABLEDtrueMaster switch to enable or bypass Leakless auditing.
max_rss_mbLEAKLESS_MAX_RSS_MB256.0Real Linux kernel RSS threshold in MB. If breached, worker recycling is triggered.
max_requestsLEAKLESS_MAX_REQUESTSnullMaximum request count per worker before triggering graceful recycling (null = unlimited).
check_transactionsLEAKLESS_CHECK_TRANSACTIONStrueAutomatically audits and rolls back open PDO transactions at request completion.
rollback_stateLEAKLESS_ROLLBACK_STATEtrueRestores default timezone, unclosed output buffers, and error reporting levels.
log_violationsLEAKLESS_LOG_VIOLATIONStrueEmits diagnostic logs when uncommitted transactions or state leaks are caught.

Released under the MIT License.