This package (anzutap-bundle) integrates AnzuTap (a data tap/observability tool) into Laravel applications. To start, install via Composer:
composer require anzusystems/anzutap-bundle
Publish the config file (if needed) and register the bundle in config/app.php under providers. The package requires Symfony 6+ (now updated for Symfony 8 compatibility in v0.12.0). Verify your Laravel/Symfony version alignment in composer.json.
First use case: Instrument a controller or service method with AnzuTap’s tap points. Example:
use AnzuTap\Bundle\AnzuTapBundle;
$tap = app(AnzuTapBundle::class)->tap('my.tap.point');
$tap->start();
try {
// Business logic here
} finally {
$tap->stop();
}
Tap Integration:
AnzuTapBundle to create taps for:
Illuminate\Http\Client events).use AnzuTap\Bundle\Event\QueryExecuted;
Event::listen(QueryExecuted::class, function ($event) {
$tap = app(AnzuTapBundle::class)->tap('db.query');
$tap->addData(['query' => $event->query]);
$tap->stop();
});
Configuration:
config/anzutap.php (publish with php artisan vendor:publish --provider="AnzuTap\Bundle\AnzuTapBundle").ANZUTAP_ENABLED=false in .env).Middleware for HTTP Taps:
public function handle($request, Closure $next) {
$tap = app(AnzuTapBundle::class)->tap('http.request');
$tap->addData(['url' => $request->url()]);
return $next($request)->thenReturn(function ($response) use ($tap) {
$tap->addData(['status' => $response->status()])->stop();
return $response;
});
}
$tap->addContext(['user_id' => auth()->id(), 'request_id' => $request->header('X-Request-ID')]);
if (app()->environment('production')) {
$tap = app(AnzuTapBundle::class)->tap('analytics.event');
// ...
}
composer require symfony/*:^8.0 --dev
vendor/bin/phpunit
config/app.php.config/anzutap.php for disabled taps or misconfigured endpoints.tap('debug.test')->start()->stop() to confirm basic functionality.stop() is called in a finally block or using try-catch to avoid incomplete taps.addData() sparingly for high-frequency taps (e.g., database queries). Sample 1 in 100:
if (rand(0, 100) < 1) {
$tap->addData(['sample' => 'data']);
}
app(AnzuTapBundle::class)->flush();
public function register() {
$this->app->singleton('custom.tap', function () {
return new CustomTapHandler();
});
}
AnzuTap\Bundle\Event\TapStarted/TapStopped for cross-cutting concerns.config/anzutap.endpoint points to your AnzuTap collector (e.g., https://collector.anzutap.com).config/anzutap.http_client to bypass SSL verification (not recommended for production).config/anzutap.php:
'debug' => env('APP_DEBUG', false),
storage/logs/laravel.log for initialization errors or tap failures.How can I help you explore Laravel packages today?