devarts / plausible-php
A PHP wrapper for using Plausible API
Installs: 56 983
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- php: ^8.0
- ext-json: *
- guzzlehttp/guzzle: ^6.3|^7.0
Requires (Dev)
- phpstan/phpstan: ^1.11
- phpunit/phpunit: ^8.0|^9.0
- symplify/easy-coding-standard: ^12.3
README
The library provides access to the Plausible API from applications written in the PHP language. It includes a pre-defined set of classes for API resources that initialize themselves from API responses.
Install
Via Composer
$ composer require devarts/plausible-php
Usage
Simple usage looks like:
use Devarts\PlausiblePHP\Configuration; use Devarts\PlausiblePHP\PlausibleApi; use Devarts\PlausiblePHP\Support\Metric; use Devarts\PlausiblePHP\Support\Filter; $plausible = new PlausibleApi(Configuration::create('plausible_api_token')); $metrics = Metric::create() ->addBounceRate() ->addVisitors(); $filters = Filter::create() ->addVisitBrowser('Chrome', Filter::NOT_EQUAL); $result = $plausible->stats()->getAggregate('example.com', [ 'metrics' => $metrics, 'filters' => $filters, ]); echo $result->bounce_rate->value;
Credits
License
The MIT License (MIT). Please see License File for more information.