kint-php/kint
Kint is a powerful PHP debugging and profiling tool that dumps variables with rich, readable output (CLI and browser). It offers deep inspection of arrays/objects, stack traces, timing/memory info, and easy integration for faster troubleshooting in any PHP project.
var_dump()/print_r()) but should never be deployed to production.error_log and output buffering, making it compatible with Laravel’s middleware stack.composer require kint-php/kint and a single use Kint\Kint; statement. No database, queue, or service provider changes needed.App\Exceptions\Handler) or middleware for automated debugging (e.g., dumping request data on errors)..env or config).kint_options(['maxDepth' => 3])) to avoid deep recursion.dd() (dump & die) or CLI-only contexts.kint_options(['renderer' => 'cli']) in web requests to force CLI output.var_dump() entirely, or supplement it for specific use cases (e.g., complex objects, backtraces)?Illuminate\Http\Request, Illuminate\Database\Eloquent\Model) that need custom formatters?App\Exceptions\Handler) or only critical ones?php artisan migrate --debug).dd() in routes/controllers for interactive inspection.var_dump() with kint() in 1–2 critical components (e.g., API controllers).kint() for complex objects, dd() for simple vars").kint($this) in controllers).var_dump() in legacy code incrementally.Illuminate\Http\Request..env to toggle Kint:
KINT_ENABLED=true # Local/staging only
if (app()->environment('production')) {
kint_options(['enabled' => false]);
}
var_dump() → kint() in shared utilities (e.g., app/Helpers/debug.php).kint() to Artisan commands for debugging command logic.App\Exceptions\Handler to dump request data on critical errors:
public function render($request, Throwable $exception) {
if ($exception instanceof \App\Exceptions\CriticalException) {
kint($request->all(), $exception);
}
return parent::render($request, $exception);
}
Laravel\Sanctum\PersonalAccessToken).kint() calls in production.kint() in non-dev branches.kint(User::all())).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Kint enabled in production | Exposes sensitive data in logs/HTML. | .env guard, CI checks, feature flags. |
| Deep recursion crashes PHP | Fatal error in CLI/web. | Set maxDepth in kint_options(). |
| Output conflicts with JSON APIs | Broken API responses. | Use kint_options(['renderer' => 'cli']) in web. |
| Plugin conflicts with other tools | Debugbar/Telescope overlap. | Isolate Kint to specific routes/commands. |
| PHP version incompatibility | Kint fails silently. | Test on PHP 8.3+; pin version in composer.json. |
var_dump() in 1–2 hours.kint() vs. var_dump() for a complex object.kint() usageHow can I help you explore Laravel packages today?