conversiontools/conversiontools-php
最新稳定版本:1.0.3
Composer 安装命令:
composer require conversiontools/conversiontools-php
包简介
Conversion Tools REST API PHP Client library
README 文档
README
Conversion Tools is an online service that offers a fast and easy way to convert documents between different formats, like XML, Excel, PDF, Word, Text, CSV and others.
This client allows to integrate the conversion of the files into PHP applications.
To convert the files PHP Client uses the public Conversion Tools REST API.
Installation
Installation using Composer
composer require conversiontools/conversiontools-php
or without composer:
require_once('conversiontools-php/src/autoload.php');
Examples
To use REST API - get API Token from the Profile page at https://conversiontools.io/profile.
Converting file
See example convert-file.php in the ./examples/ folder.
<?php require_once __DIR__ . '/vendor/autoload.php'; use \ConversionTools\ConversionClient; // put token here from your Profile page at https://conversiontools.io/profile $token = ''; $fileOrUrlInput = 'test.xml'; $fileOutput = 'test.csv'; $options = ['delimiter' => 'tabulation']; $client = new ConversionClient($token); try { $client->convert('convert.xml_to_csv', $fileOrUrlInput, $fileOutput, $options); } catch (Exception $e) { print 'Exception: ' . $e->getMessage() . "\n"; }
Converting URL
See example convert-url.php in the ./examples/ folder.
<?php require_once __DIR__ . '/vendor/autoload.php'; use \ConversionTools\ConversionClient; // put token here from your Profile page at https://conversiontools.io/profile $token = ''; $fileOrUrlInput = 'https://google.com'; $fileOutput = 'result.pdf'; $options = []; $client = new ConversionClient($token); try { $client->convert('convert.website_to_pdf', $fileOrUrlInput, $fileOutput, $options); } catch (Exception $e) { print 'Exception: ' . $e->getMessage() . "\n"; }
API
Create ConversionClient instance with a token.
use \ConversionTools\ConversionClient; $client = new ConversionClient('<token>');
Where <token> is API token from the account's Profile page https://conversiontools.io/profile.
Convert input file and download the result
$client = new ConversionClient($token); try { $client->convert('<conversion type>', $fileOrUrlInput, $fileOutput, $options); } catch (Exception $e) { print 'Exception: ' . $e->getMessage() . "\n"; }
Where
<conversion type>is a specific type of conversion, from API Documentation.$fileOrUrlInputis the filename of the input file, or URL of the file to convert (when applicable)$fileOutputis the filename of the output file$optionsis a PHP array with options for a corresponding converter, for example:
$options = ['delimiter' => 'tabulation'];
Requirements
PHP version 5.4.0 or later.
Documentation
List of available Conversion Types and corresponding conversion options can be found on the Conversion Tools API Documentation page.
License
Licensed under MIT.
Copyright (c) 2021 Conversion Tools
统计信息
- 总下载量: 6.5k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04