fond-of/php-airtable-sdk

This package is abandoned and no longer maintained. No replacement package was suggested.

Client Library for the Airtable API

1.0.0-beta.2 2020-05-18 11:06 UTC

This package is auto-updated.

Last update: 2022-05-25 14:11:13 UTC


README

This repository is discontinued without any replacement.

Scrutinizer Code Quality

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.