The Storage API PHP client library is a portable command line client providing the most complete Storage API implementation. It runs on any platform which has PHP installed. Currently this client implements almost all Storage API functions including, of course, exporting and importing tables.
The client source is available in our Github repository.
On Windows, use the installer.
To install the library, run
in the root of your project. You should get an output similar to this one:
Using version ^4.11 for keboola/storage-api-client
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing aws/aws-sdk-php (3.18.18)
- Installing keboola/storage-api-client (4.11.0)
Writing lock file
Generating autoload files
Then add the generated autoloader in your bootstrap script:
The Storage API client is implemented as a single class. To create an instance of the class, provide a Storage API token to the constructor.
To create a new table in Storage, it is recommended to use an additional php-csv library to work with CSV files. The library will get installed automatically with the Storage API client, so you can use it out of the box. To create a new table and import CSV data in it, use the following PHP script:
To import CSV data into an existing table and overwrite its contents, use the following PHP script:
To import CSV data into an existing table and append the new data to the existing table contents, use the following PHP script:
All available upload options are listed in the API documentation.
To export data from a Storage table to a CSV file, use the
TableExporter class. It is part of the client library. You can use the following script: