Download the PHP package conversiontools/conversiontools-php without Composer
On this page you can find all versions of the php package conversiontools/conversiontools-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download conversiontools/conversiontools-php
More information about conversiontools/conversiontools-php
Files in conversiontools/conversiontools-php
Package conversiontools-php
Short Description Conversion Tools REST API PHP Client library
License MIT
Homepage https://github.com/conversiontools/conversiontools-php
Informations about the package conversiontools-php
Conversion Tools PHP Client
Conversion Tools is an online service for converting files between formats — XML, Excel, PDF, Word, CSV, JSON, images, audio, video, and more.
This library integrates file conversion into PHP applications via the Conversion Tools REST API.
Requirements
- PHP 8.1 or later
- ext-curl, ext-json (enabled by default in standard PHP installs)
Installation
Quick Start
Get your API token from conversiontools.io/profile.
Examples
Convert a file
Convert a URL
Use a pre-uploaded file
Manual control (upload → task → wait → download)
Fire and forget (webhook)
Error handling
API
new ConversionToolsClient(array $config)
| Key | Type | Default | Description |
|---|---|---|---|
api_token |
string | required | API token from your profile |
base_url |
string | https://api.conversiontools.io/v1 |
API base URL |
timeout |
float (ms) | 300000 |
Request timeout |
retries |
int | 3 |
Retry attempts on transient errors |
retry_delay |
float (ms) | 1000 |
Initial retry delay (doubles each attempt) |
polling_interval |
float (ms) | 5000 |
How often to poll task status |
max_polling_interval |
float (ms) | 30000 |
Max polling interval (with backoff) |
polling_backoff |
float | 1.5 |
Polling backoff multiplier |
webhook_url |
string | null |
Default webhook URL for all tasks |
on_conversion_progress |
callable | null |
Called on each poll with progress info |
convert(string $conversionType, string|array $input, ?string $output, array $options, bool $wait, ?string $callbackUrl): string
One-call conversion. Returns the output file path (if $wait=true) or task ID (if $wait=false).
Input formats:
'path/to/file.pdf'— local file path['url' => 'https://...']— URL-based conversion['file_id' => '...']— pre-uploaded file
createTask(string $conversionType, array $options, ?string $callbackUrl): Task
Create a task without waiting. Returns a Task object.
getTask(string $taskId): Task
Retrieve an existing task by ID.
getRateLimits(): ?array
Returns rate limit info from the last API response.
Task
| Method | Description |
|---|---|
wait(array $options = []) |
Poll until complete. Accepts polling_interval, max_polling_interval, timeout, on_progress |
downloadTo(?string $path) |
Download result to file, returns resolved path |
downloadBytes() |
Download result as string |
refresh() |
Re-fetch status from API |
getStatus() |
Returns current status string |
isSuccess() / isError() / isRunning() / isComplete() |
Status helpers |
toArray() |
Serialize task state |
$client->files
| Method | Description |
|---|---|
upload(string $filePath): string |
Upload file, returns file_id |
getInfo(string $fileId): array |
Get file metadata |
downloadBytes(string $fileId): string |
Download as string |
downloadTo(string $fileId, ?string $outputPath): string |
Download to file |
$client->tasks
| Method | Description |
|---|---|
create(array $request): array |
Create task (low-level) |
getStatus(string $taskId): array |
Get task status |
list(?string $status): array |
List tasks, optionally filtered by status |
Exceptions
All exceptions extend ConversionToolsException and expose $errorCode and $httpStatus.
| Exception | Trigger |
|---|---|
AuthenticationException |
Invalid or missing API token |
ValidationException |
Bad request parameters |
RateLimitException |
Quota exceeded — has $limits property |
FileNotFoundException |
File ID not found |
TaskNotFoundException |
Task ID not found |
ConversionException |
Task failed — has $taskId and $taskError |
TimeoutException |
Request or polling timed out |
NetworkException |
Connection error |
Documentation
Full list of conversion types and options: conversiontools.io/api-documentation
License
Licensed under Conversion Tools