2017 © Pedro Peláez
 

library count

image

itsoneiota/count

  • Friday, September 9, 2016
  • by rossmcf
  • Repository
  • 4 Watchers
  • 0 Stars
  • 2,198 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 12 % Grown

The README.md

One iota Metrics Components

Background

This a very slightly modified version of Etsy's StatsD example for PHP. The Counter class provides a static registry (It's a singleton. Don't even start.) for StatsD instance, allowing it to be accessed from every nook and cranny of an application., (*1)

Installing

This library is best installed using Composer. Include the generated Composer autoloader (usually vendor/autoload.php)., (*2)

Configuring

The StatsD class has two constructor arguments, host and port., (*3)

Initialising

The bare minimum you need to do is instantiate StatsD with your server settings and you're good to go., (*4)

To make sending metrics more accessible around your application, you can use the Counter static registry., (*5)

$statsD = new StatsD($myHost, $myPort);
Counter::setInstance($statsD);

...

Counter::increment('hits');

Testing Collaborators with MockStatsD

If you need to test that a class is sending statistics as you expect, you can create an instance of MockStatsD, which can report on the current value of counters being incremented/decremented. At present, MockStatsD can only report on counters., (*6)

$statsD = new MockStatsD();
Counter::setInstance($statsD);

... test test test ...

$fooCount = $statsD->getCounter('foo');

The Versions

09/09 2016

dev-master

9999999-dev

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

09/09 2016

1.0.0

1.0.0.0

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires