> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP SDK requests, types, and pagination

> Value objects, file uploads, and pagination.

## Value Objects

It is recommended to use the static `with` constructor `AzureVoiceSettings::with(type: 'azure', ...)`
and named parameters to initialize value objects.

However, builders are also provided `(new AzureVoiceSettings)->withType('azure')`.

## File uploads

Request parameters that correspond to file uploads can be passed as a resource returned by `fopen()`, a string of file contents, or a `FileParam` instance.

```php theme={null}
<?php

use Telnyx\Core\FileParam;

// Pass a string with filename and content type:
$contents = file_get_contents('/path/to/file');
// Pass a string with filename and content type:
$response = $client->ai->audio->transcribe(
  file: FileParam::fromString($contents, filename: '/path/to/file', contentType: '…'),
);

// Pass in only a string (where applicable)
$response = $client->ai->audio->transcribe(file: '…');

// Pass an open resource:
$fd = fopen('/path/to/file', 'r');
try {
  $response = $client->ai->audio->transcribe(
    file: FileParam::fromResource($fd, filename: '/path/to/file', contentType: '…'),
  );
} finally {
  fclose($fd);
}
```

## Pagination

List methods in the Telnyx API are paginated.

This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:

```php theme={null}
<?php

use Telnyx\Client;

$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');

$page = $client->accessIPAddress->list(pageNumber: 1, pageSize: 50);

var_dump($page);

// fetch items from the current page
foreach ($page->getItems() as $item) {
  var_dump($item->id);
}
// make additional network requests to fetch items from all pages, including and after the current page
foreach ($page->pagingEachItem() as $item) {
  var_dump($item->id);
}
```
