Skip to content

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.

License

Notifications You must be signed in to change notification settings

therohitdas/plausible-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plausible PHP

Build Status Latest Stable Version License

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.

Requirements

PHP 7.4 and later.

Install

Via Composer

$ composer require devarts/plausible-php

Usage

Simple usage looks like:

use Devarts\PlausiblePHP\PlausibleAPI;
use Devarts\PlausiblePHP\Support\Period;
use Devarts\PlausiblePHP\Support\Metric;
use Devarts\PlausiblePHP\Support\Filter;

$plausible = new PlausibleAPI('{plausible_api_token}');

$metrics = Metric::create()->addBounceRate()->addVisitors();
$filters = Filter::create()->addVisitBrowser('Chrome', Filter::NOT_EQUAL);

$timeseries = $plausible->getTimeseries('example.com', [
    'period'  => Period::DAYS_30,
    'metrics' => $metrics->toString(),
    'filters' => $filters->toString(),
]);

foreach ($timeseries as $timepoint) {
    echo "{$timepoint->date->format('Y-m-d')} | {$timepoint->bounce_rate} | {$timepoint->visitors}";
}

Credits

License

The MIT License (MIT). Please see License File for more information.

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%