About this project

Laravel Plausible is a package that brings Plausible Analytics into Laravel applications. It provides a simple facade to interact with the Plausible Stats API, allowing developers to fetch realtime visitor numbers, aggregated metrics, time series data, and breakdowns by various properties. Installation is done via Composer with the command composer require njoguamos/laravel-plausible, followed by php artisan plausible:install to publish the configuration file. After installation, users must add their Plausible site ID and API key to the .env file, and optionally set PLAUSIBLE_BASE_URL for self‑hosted instances. The package offers several methods: Plausible::realtime() returns the current visitor count; Plausible::aggregates() retrieves summary metrics with optional parameters for period, metrics, comparison, filters, date range, and imported data inclusion; Plausible::timeSeries() returns data points over time with configurable interval; Plausible::breakdown() provides stats grouped by a property such as page, browser, or country, with support for limits, pagination, and filtering. To reduce API calls, responses are cached for three minutes by default, but the cache duration and driver can be adjusted via PLAUSIBLE_CACHE_DURATION and PLAUSIBLE_CACHE_DRIVER environment variables, or caching can be disabled entirely with PLAUSIBLE_CACHE=false. The package includes a test suite runnable with composer test and follows standard Laravel contribution guidelines.