# PHP

The PHP SDK is the PHP client for the `antd` daemon.

## Install

```bash
composer require autonomi/antd
```

## Connect to the daemon

```php
<?php

require_once 'vendor/autoload.php';

use Autonomi\Antd\AntdClient;

$client = new AntdClient('http://localhost:8082');
$health = $client->health();
echo $health->network . PHP_EOL;
```

## Store and retrieve data

```php
<?php

require_once 'vendor/autoload.php';

use Autonomi\Antd\AntdClient;

$client = new AntdClient();
$result = $client->dataPutPublic('Hello, Autonomi!');
echo $result->address . PHP_EOL;

$data = $client->dataGetPublic($result->address);
echo $data . PHP_EOL;
```

## Type mappings

| Autonomi type  | PHP type        |
| -------------- | --------------- |
| `HealthStatus` | response object |
| `PutResult`    | response object |
| Raw data       | `string`        |

## Error handling

```php
<?php

use Autonomi\Antd\Errors\NotFoundError;
use Autonomi\Antd\Errors\PaymentError;

try {
    $client->dataGetPublic('bad-address');
} catch (NotFoundError $e) {
    echo "Data not found\n";
} catch (PaymentError $e) {
    echo "Insufficient funds\n";
}
```

## Full API reference

For all available daemon endpoints, see the [REST API](/developers/sdk/install/reference/rest-api.md).


---

# 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.autonomi.com/developers/sdk/install/reference/language-bindings/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.
