Download the PHP package zadorin/airtable-php without Composer

On this page you can find all versions of the php package zadorin/airtable-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package airtable-php

Airtable PHP client

Installation

composer require zadorin/airtable-php

Please note that library requires PHP 8.2 since v1.0.0 release.

If you have lower PHP version, use v0.*.* releases:

composer require zadorin/airtable-php:^0

Usage

Basic setup

You can find API key in your account settings and database name in API Docs.

Insert some rows

Fetch multiple rows

Fetch specific rows by record id

Iterate and update records

Pagination

Remove rows

Complex filters

You can build complex formulas to filter records, but be careful, because formula applies to each record and can slow down your query.

Assume we prepared following query object:

Query builder

The following lines give the same results:

You can use different logical operators:

It's possible to concat multiple where statements:

Or chain methods to achieve the same result:

OR-logic

Methods where(), andWhere(), orWhere() use the same signature, so you can combine them:

Regex filtering

Besides logical operators, you can use keywords like and match in your where-statements.

Keyword match allows you to apply REGEXP_MATCH() function to your filter formula. Airtable's REGEX functions are implemented using the RE2 regular expression library, so be sure that syntax of your regular expression is correct:

Keyword like also uses REGEXP_MATCH() under the hood, but provides more SQL-like syntax:

Please note, that like is case-sensitive, so if you want to ignore case, you'd better use match with i-flag.

Date filtering

Library provides few methods to filter records by date and time:

First parameter is your column name.

You can pass DateTimeImmutable object or datetime string, which will be cast into DateTimeImmutable automatically.

You can filter records by date range instead of strict equality:

There are shortcuts for that purpose:

When searching by date (not datetime), library applies range filter under the hood. For example, $query->whereDate('meeting', '2022-03-08') will actually search records between 2022-03-08 00:00:00 and 2022-03-08 23:59:59, including left and right borders.

Please note that the library does not perform any timezone conversions, so most reliable solution is to specify GMT timezone in your DateTimeImmutable objects, and set flag Use the same time zone (GMT) for all collaborators in your datetime column settings.

Raw formula

You can see what exact formula was built:

Also, you can filter records by raw formula:

All query builder methods are used to make raw formula under the hood. It means that if the functionality of query builder is not enough, you can always use raw formula instead.

Note that library don't validate raw formulas so you can get exception from Airtable API.

View

Sometimes it is more convenient to create a specific table view with predefined sorting and filters, instead of building a complex query in the source code.

Assuming you have tasks table and active tasks view containing only active tasks ordered by priority:

You can combine view and additional filters, specify subset of selected fields and override order just like normal select query:

You can use alias andWhereView() but method orWhereView() will throw LogicError. This is because view is not actually part of the filter formula, it always works like "view AND formula", so you can't use OR operator here.

Also note that if view not exists RequestError exception will be thrown.

Macros

You can extend query builder methods with your own using macros:

Macro name must not start with or/and. These logic prefixes are reserved and handles automatically.

Context $this inside macro callback references to query builder instance. It allows you to use other query builder methods or even other macros:

You can pass variables into macro callback:

And of course you can use raw formula to build something more complex:

But remember that raw formula overrides other query builder setup.

Typecast

Airtable supports linked fields, which references other rows from current or another table. Assume you have users table where contacts field is a link to row in another table.

By default, you have to specify concrete row ID while inserting or updating such fields:

It's not very handy, so Airtable API supports typecast parameter, which enables automatic data conversion from string values.

Automatic conversion is disabled by default to ensure data integrity, but sometimes it may be helpful.

This is how you can enable that feature:

Update queries works the same.

Throttling

Airtable API is limited to 5 requests per second per base. Client uses simple throttling library to keep this limit.

You can disable this behavior:

Debug

Client keeps last request object so you can use this for debugging purposes.

Be careful with debug information because it contains all HTTP headers including authorization token

Exceptions

All package exceptions inherits from common Zadorin\Airtable\Errors\AirtableError class.

Also you may be interested in Zadorin\Airtable\Errors\RequestError which contains last request instance:

Known problems

Client uses ext-curl to make requests and ext-json to encode/decode results. Make sure this php extensions installed and properly configured.

If you see SSL certificate problem: unable to get local issuer certificate you probably have to configure option curl.cainfo in your php.ini. Source

License and contributing

MIT License. Any feedback is highly appreciated — welcome to issues.

If you want to send pull request make sure all tests are pass.

Tests

Copy this readonly test database into your Airtable account, then fill env variables specified in phpunit.xml.dist.

And finally run test suite:

./vendor/bin/pest

It's also recommended to use static analysis tool to avoid errors:

./vendor/bin/psalm

All versions of airtable-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-curl Version *
ext-json Version *
davedevelopment/stiphle Version ^0.9.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zadorin/airtable-php contains the following files

Loading the files please wait ....