2017 © Pedro PelĂĄez
 

library stats-writer

Php Stats Writer

image

heapstersoft/stats-writer

Php Stats Writer

  • Monday, November 26, 2012
  • by p1r0
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Stats

Intro

Stats is a small php project to help using stats from your current project. It supports any backend for which you want to write an adapter and it comes with one for statsd., (*1)

Installing

No actual installation is needed just add this to your composer.json require section:, (*2)

    "heapstersoft/stats-writer": "1.0.x-dev"

Usage

First of all you need to include your composer autoload as with any project using composer:, (*3)

    require 'vendor/autoload.php';

ideally you would do this in one central place and only once., (*4)

Then to send a stat to the backend (see configuration section) you need to create a stats object passing the config file as a first paramenter and the just use either increment or decrement:, (*5)

    $statWriter = new \Heapstersoft\Stats\Writer('config/stats.yml');

    $statWriter->increment('key1');

For more information I encourage you to view the source code., (*6)

Congfiguration

Stats uses a simple YAML file as configuration with a mandatory "Adapter" key., (*7)

Under adapter you just neet the adapter class. The rest of the parameters ara adapter specific., (*8)

For an example configuration see the StatsD adapter section., (*9)

Adapters

StatsD

Example configuration file for StatsD:, (*10)

    Adapter:
      class: \Heapstersoft\Stats\Adapter\StatsD
      host: "127.0.0.1"
      port: 8125
      key: "#host#.test.#key#"

All parameter should be self explainatory except for the "key" parameter., (*11)

Key allows you to customize the key string sent to the statsd backend. It suports any string with some special placeholders., (*12)

Right now these placeholders are: #host# that is replaced by the $_SERVER['HTTP_HOST'] variable and the #key# that is replaced for the value you pass to increment or decremant., (*13)

If no #key# is spcecified, it is appended., (*14)

The Versions

26/11 2012

dev-master

9999999-dev http://heapstersoft

Php Stats Writer

  Sources   Download

MIT

The Requires

 

by Tabaré Caorsi

php stats statsd