webpractik / ocf-converter-sdk
SDK for onlineconvertfree.com file conversion API
1.0.0
2022-11-14 08:35 UTC
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2025-03-14 14:38:23 UTC
README
SDK for onlineconvertfree.com file conversion API.
Installation & Usage
Requirements
PHP 7.4 and later. Should also work with PHP 8.0.
Composer
The recommended way to install SDK is through Composer.
composer require webpractik/ocf-converter-sdk
Getting Started
Please follow the installation procedure and then start from the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); $apiKey = 'myApiKey'; $client = new Webpractik\OcfConverter\Sdk\OcfClient($apiKey); $filePath = '/path/to/file/to/convert.png'; $extensionToConvertTo = 'pdf'; try { $task = $client->uploadFile($filePath, $extensionToConvertTo); $result = $task->waitForConversion(); if ($result->isSuccess()) { $resultUrl = $result->getResultingFileUrl(); $resultFileName = basename($resultUrl); if (file_put_contents($resultFileName, file_get_contents($resultUrl))) { $result->deleteFile(); } } } catch (Exception $e) { echo 'Exception: ', $e->getMessage(), PHP_EOL; }
License
SDK is made available under the MIT License (MIT). Please see License File for more information.
Contribution
OpenAPI Generator is used for the client generation.
Requirements
JRE and OpenAPI Generator are required for the client generation.
Client generation
To regenerate the client do the following:
- run generation command:
composer api-codegen
- reformat the generated code with your IDE.