Giter VIP home page Giter VIP logo

plausible-php's Introduction

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.

plausible-php's People

Contributors

marko-ogg avatar philsturgeon avatar marcqualie avatar robloach avatar bcrowe avatar barryvdh avatar bencorlett avatar swader avatar nyamsprod avatar anahkiasen avatar pborreli avatar therohitdas avatar zackkitzmiller avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.