Weave Code
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
Prometheus Client Php

Prometheus Client Php Laravel Package

promphp/prometheus_client_php

Prometheus client library for PHP with counters, gauges, histograms, and summaries. Supports Redis, Predis, APCu/APCng, or in-memory storage for metric aggregation across workers, with simple APIs to register, update, and expose metrics for scraping.

View on GitHub
Deep Wiki
Context7

Prometheus instrumentation library for PHP applications

Frequently asked questions about Prometheus Client Php
How do I integrate this Prometheus client into a Laravel application?
Start by requiring the package via Composer (`composer require promphp/prometheus_client_php`), then register the `CollectorRegistry` as a Laravel service provider singleton. Use middleware to auto-instrument HTTP requests or manually register metrics in your business logic. Expose metrics via a `/metrics` route using `RenderTextFormat`.
Which storage adapter should I use for Laravel queue workers?
For Laravel queue workers running in multiple processes, use the **Redis adapter** to ensure metrics are aggregated across workers. If Redis isn’t available, **APCu** is a lightweight alternative for shared-memory environments. Avoid the in-memory adapter for long-running workers, as it won’t persist metrics.
Does this package support Laravel’s service container and facades?
Yes, the package integrates seamlessly with Laravel’s service container. Bind the `CollectorRegistry` as a singleton in your service provider and optionally create a facade (e.g., `Metrics`) for cleaner syntax. This follows Laravel’s conventions and simplifies dependency injection.
Can I track HTTP request metrics like response time and status codes?
Absolutely. Use middleware to wrap Laravel’s HTTP pipeline and instrument metrics like `response_time_seconds` (histogram) or `http_requests_total` (counter with labels for status codes, routes, or methods). The package’s lightweight API makes this easy to implement in under 5 lines of code.
What Laravel versions and PHP versions are supported?
The package supports **PHP 8.0+** and is compatible with **Laravel 8.x, 9.x, and 10.x**. It follows modern PHP practices and avoids deprecated features. Always check the package’s `composer.json` for the latest version requirements, as minor updates may introduce breaking changes.
How do I handle metrics for cron jobs or long-running scripts?
For cron jobs or scripts, use the **in-memory adapter** if metrics don’t need persistence across requests. For shared state, use **Redis** or **APCu**. Ensure your script initializes the `CollectorRegistry` early and exposes metrics via a temporary endpoint or CLI output if needed.
Are there performance considerations when using Redis or APCu?
Redis adds network overhead, so benchmark its impact in staging. **APCu** is faster but limited to shared-memory environments. For high-throughput apps, consider **Predis** (a Redis client) or tune Redis persistence settings. The in-memory adapter is fastest but unsuitable for multi-process setups.
How do I define custom metric names or labels for Laravel-specific use cases?
Use the `getOrRegister*()` methods with a namespace prefix (e.g., `laravel_`) or labels like `app=laravel`, `route=home`, or `status=500`. This ensures consistency with other Laravel observability tools like Telescope or Sentry. Example: `$counter->inc(['route' => 'checkout']);`.
Can I use this with Laravel’s queue system (e.g., Horizon or Forge)?
Yes, instrument queue jobs by registering metrics in `handle()` methods or using event listeners for `JobProcessed`. Use the **Redis adapter** to aggregate metrics across worker processes. Example: Track `queue_job_duration_seconds` as a histogram in your job class.
What alternatives exist for Prometheus metrics in Laravel?
Alternatives include **spatie/laravel-prometheus** (Laravel-specific wrapper) or **humankode/laravel-prometheus** (simpler API). However, `promphp/prometheus_client_php` offers more flexibility with adapters (Redis, APCu, PDO) and better multi-worker support. Choose based on your need for granularity or ease of setup.
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope