# PHP

### Interesting PHP Metrics Libraries

* **PHP StatsD**\
  <https://github.com/domnikl/statsd-php> - A PHP StatsD client available in Composer\
  <https://github.com/seejohnrun/php-statsd> - A simple PHP StatsD client

### Sending a metric via TCP

```php
<?
    $conn = fsockopen("carbon.hostedgraphite.com", 2003);
    fwrite($conn, "YOUR-API-KEY.foo.php-tcp 1.2\n");
    fclose($conn);
?>
```

### Sending a metric via UDP

```php
<?
    $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
    $message = "YOUR-API-KEY.foo.php-udp 1.2\n";
    socket_sendto($sock, $message, strlen($message), 0, "carbon.hostedgraphite.com", 2003);
?>
```

### Sending a metric via UDP on Heroku

```php
<?

     $fp = fsockopen('udp://carbon.hostedgraphite.com', 2003);
     fwrite($fp, "YOUR-API-KEY.foo.php-heroku 1.2\n");
     fclose($fp);
?>

```

Your API key can be found on your [account home](https://www.hostedgraphite.com/accounts/profile/) page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hostedgraphite.com/language-guide/php.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
