1. Go to this page and download the library: Download liuggio/statsd-php-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Liuggio\StatsdClient\StatsdClient,
Liuggio\StatsdClient\Factory\StatsdDataFactory,
Liuggio\StatsdClient\Sender\SocketSender,
Liuggio\StatsdClient\Service\StatsdService;
// use Liuggio\StatsdClient\Sender\SysLogSender;
$sender = new SocketSender(/*'localhost', 8126, 'udp'*/);
// $sender = new SysLogSender(); // enabling this, the packet will not send over the socket
$client = new StatsdClient($sender);
$factory = new StatsdDataFactory('\Liuggio\StatsdClient\Entity\StatsdData');
$service = new StatsdService($client, $factory);
// create the metrics with the service
$service->timing('usageTime', 100);
//...
// send the data to statsd
$service->flush();
use Liuggio\StatsdClient\StatsdClient,
Liuggio\StatsdClient\Factory\StatsdDataFactory,
Liuggio\StatsdClient\Sender\SocketSender;
// use Liuggio\StatsdClient\Sender\SysLogSender;
use Monolog\Logger;
use Liuggio\StatsdClient\Monolog\Handler\StatsDHandler;
$sender = new SocketSender(/*'localhost', 8126, 'udp'*/);
// $sender = new SysLogSender(); // enabling this, the packet will not send over the socket
$client = new StatsdClient($sender);
$factory = new StatsdDataFactory();
$logger = new Logger('my_logger');
$logger->pushHandler(new StatsDHandler($client, $factory, 'prefix', Logger::DEBUG));
$logger->addInfo('My logger is now ready');
bash
composer
git clone git://github.com/liuggio/statsd-php-client.git
cd statsd-php-client
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.