devlion / converter-php-client
Devlion Converter API client for PHP
Requires
- php: >=5.5
- guzzlehttp/guzzle: ^6.3
This package is auto-updated.
Last update: 2024-09-17 07:24:22 UTC
README
Installation via Composer
The recommended method to install is through Composer.
-
Add
devlion/converter-php-client
as a dependency in your project'scomposer.json
:{ "require": { "devlion/converter-php-client": "*" } }
-
Download and install Composer:
curl -s http://getcomposer.org/installer | php
-
Install your dependencies:
php composer.phar install
-
Require Composer's autoloader
Composer also prepares an autoloader file that helps to autoload the libraries it downloads. To use it, just add the following line to your application:
<?php require 'vendor/autoload.php'; use Devlion\Converter\Client; $client = new Client('token');
You can find out more about Composer at getcomposer.org.
Methods:
Convert:
Put a database file and convert to specified database & save as zip file.
$inputFiles = ['/samples/sample.mdf']; $options = ['outputFormat' => 'csv']; $client->convert($inputFiles, $options)
Extract:
Unzip converted file.
$client->extract();
getZipFilePath:
Get converted zip file path.
$client->getZipFilePath();
getExtractedDirectory:
Get extracted directory path.
$client->getExtractedDirectory();
Methods below work only for csv outputType
getDatabases:
Get converted databases array.
$databases = $client->extract()->getDatabases();
getTables:
Get list of tables for selected database.
$tables = $client->getTables('sample');
getTableRows:
Get data of selected table.
$rows = $client->getTableRows('POINTS_TABLE');
getDatabasesTables:
Get all converted databases and all tables for each database.
$data = $client->getDatabasesTables();
getDatabasesTableRows:
Get rows of selected table for each database where table exists.
$data = $client->getDatabasesTableRows('POINTS_TABLE');
Example
The following code is an example on how to convert a Microsoft Sql Server file (.MDF) to a ZIP-archive of CSV files. You should replace 'token' with the Customer Token that you purchased.
use Devlion\Converter\Client; $client = new Client('token'); $inputFiles = ['/samples/sample.mdf']; $databases = $client->convert($inputFiles, $options)->extract()->getDatabases(); $outputFile = $client->getZipFilePath(); echo "Conversion successful, check out $outputFile!\n"; echo "<pre>"; print_r($databases);
License
This code is licensed under the MIT license.