fond-of / php-airtable-sdk
Client Library for the Airtable API
Installs: 5 090
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7.3
- ext-json: *
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- codeception/codeception: ^4.1
- php-coveralls/php-coveralls: ^2.2
- phpmd/phpmd: ^2.8
- phpro/grumphp-shim: ^0.18
- phpstan/phpstan: ^0.12
- roave/security-advisories: dev-master as 1.0.0
- sebastian/phpcpd: ^5.0
- sllh/composer-versions-check: ^2.0
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2022-05-25 14:11:13 UTC
README
This repository is discontinued without any replacement.
The Airtable SDK for PHP allows you to read and write data to Airtable via API. The library comes with a single dependency which is Guzzle 6.x.
Installation
The SDK can be installed via composer:
composer require fond-of/php-airtable-sdk
Usage
<?php require __DIR__ . '/vendor/autoload.php'; use FondOf\Airtable\{Table, Airtable}; $base = 'baseId'; $table = 'tableId'; $client = (new Airtable([ 'apiKey' => '1234567' ]))->createApiClient(); $table = new Table($client, $base, $table);
Read a single record
$record = $table->getRecord($recordId);
Read multiple records
$records = $table->getRecords();
Write a record
$fields = [ 'Name' => 'Foobar', 'Notes' => 'This is an example', 'Attachments' => [ [ 'url' => 'https://foobar.jpg', 'filename' => 'Example' ], ] ]; $table->writeRecord($fields);
Increase record limit(Defaults to 10)
$records = $table->limit(50)->getRecords();
max limit is 100
Change table or base
You don't need to create a new table in order to access another table or base. There are two options
to change them one is via setter function and the other option is a fluent api.
$records = $table->base('baseId')->table('tableId')->getRecords(); $table = $table->setBase('baseId'); $table = $table->setTable('tableId'); $records = $table->getRecords();
Contributing
Feel free to open issues and pull requests.
To run tests and code sanatizer you can run the following:
make grumphp
If you would like to run only tests use:
make codeception
License
Please see the license file for more information.