Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Api Logger Bundle Laravel Package

gamma/api-logger-bundle

A lightweight logging bundle for APIs that captures requests, responses, and errors for easier debugging and monitoring. Helps trace issues across endpoints with minimal setup in Laravel/PHP applications.

View on GitHub
Deep Wiki
Context7

Getting Started

Before anything else, understand what this package actually is: despite the api-logger name, gamma/api-logger-bundle is a Symfony-style bundle for the Gamma PHP framework (smart-gamma/gamma), not a Laravel package. There is no service provider, no config/api-logger.php, and no facade. A Laravel developer's realistic first step is to read the source as a reference implementation and port the logging/profile middleware pattern into Laravel's HTTP client and middleware stack.

If you are actually on a Gamma/Symfony app:

  1. composer require gamma/api-logger-bundle — pin the exact version (2018-07-15 tag). Expect PHP 7.1/7.2-era constraints and Symfony 3.x/4.x transitive dependencies; Composer will likely block install on PHP 8+/Symfony 5+ without --ignore-platform-reqs.
  2. Register the bundle in the Gamma app bootstrap (equivalent to AppKernel::registerBundles) or the framework's bundle config file.
  3. Import the bundle's default config (config.yml / services.yml) and set the PSR-3 logger channel and log level — check the DependencyInjection/Configuration.php file in the repo for the exact keys, since there is no published docs.
  4. First use case: wrap your outbound REST client (Guzzle or the framework's HTTP client) so every request logs method, URI, status code, and duration. That is the single lowest-risk capability to validate before relying on anything else.

Where to look first, in order: README.md → DependencyInjection/Configuration.php (reveals all config keys) → the event subscriber / middleware class that does the actual logging → tests (if any) for expected log shape.

Implementation Patterns

Decorator around the HTTP client. The safest pattern is to wrap your client in a decorator that logs before/after each call. If you're porting to Laravel, this is a natural fit for GuzzleHttp\HandlerStack middleware or a custom Illuminate\Http\Client macro:

$stack->push(Middleware::tap(
    fn ($req) => $log->debug('api.request', ['method' => $req->getMethod(), 'uri' => (string) $req->getUri()]),
    fn ($req, $res) => $log->info('api.response', ['status' => $res->getStatusCode(), 'ms' => ...])
));

Correlation IDs. Generate a request ID per inbound Laravel request (middleware) and inject it into every outbound log context. The bundle's older logging likely predates this convention, so add it yourself — it's the highest-value change.

Profiling as timing spans. The "profiling" half is usually just microtime(true) deltas around the request. Record them as structured fields (duration_ms, bytes, status) rather than free-text, so they're queryable in Loki/ELK/Datadog.

Channel separation. Log API traffic to a dedicated channel with its own retention and level. In Laravel: a api channel in config/logging.php. Do not pour request bodies into laravel.log.

Sampling and failure-only modes. Daily traffic will drown you. Log all 4xx/5xx at warning, sample successful 2xx (e.g. 1 % or 10 %), and always log 5xx. The bundle itself has no sampling toggle — build it in the decorator.

Integration with testing. In tests, bind a NullLogger (or a TestLogger that asserts context) so the decorator doesn't spam output. Assert the shape of the context array, not the message string.

Gotchas and Tips

  • It's abandoned. Last release July 2018, zero stars, zero dependents. Treat the package as unmaintained and assume no security fixes. Do not put it on a production dependency path without vendoring or forking.
  • Framework mismatch. It is not Laravel. There is no config/app.php provider entry, no artisan command, no Blade of config help. The concepts port cleanly; the code does not.
  • PHP/PSR drift. Written against PHP 7.1-era types and probably PSR-3 LoggerInterface. composer install on PHP 8.2+ will fail platform checks; --ignore-platform-reqs will get you past it but leave you debugging TypeErrors from older signatures.
  • Secret leakage is the big pitfall. Auth headers, tokens in query strings, and request bodies routinely contain credentials. Redact Authorization, Cookie, Set-Cookie, and any *_token keys before the context hits the logger. The bundle will not do this for you.
  • Debugging logging failures. Because the bundle registers middleware/subscribers through the container, a silent failure usually means the service tag didn't register. Log a debug line in the subscriber's __construct to confirm it's instantiated. bin/console debug:container is your friend on Symfony; php artisan about / container dumps on a port.
  • Log volume and cost. Unsampled API logging is the top cause of surprise ingestion bills. Cap context size (truncate bodies to e.g. 2 KB), and set a retention policy on the channel.
  • Timezones/clock skew. Duration calculated from two microtime(true) calls is fine; timestamps from database clocks or NTP-skewed hosts are not. Use a monotonic-enough clock consistently in one place.
  • Extension points are thin. Expect the bundle to be a small subscriber; if you need more than method/URI/status/duration, fork it rather than fight it. The README on GitHub is the only documentation — read the source, not the prose.
  • Recommendation for a Laravel team: skip the dependency entirely. A 60-line Guzzle middleware + a dedicated api log channel gives you 95 % of what this bundle offers, with modern PHP support and no 2018 baggage.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle