dev-master
9999999-dev http://heapstersoftPhp Stats Writer
MIT
The Requires
- php >=5.3.2
- symfony/yaml *
by Tabaré Caorsi
php stats statsd
Wallogit.com
2017 © Pedro PelĂĄez
Php Stats Writer
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)
No actual installation is needed just add this to your composer.json require section:, (*2)
"heapstersoft/stats-writer": "1.0.x-dev"
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)
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)
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)
Php Stats Writer
MIT
php stats statsd