GiveItARest logo


Harmonic Data Associates, Inc.


Product Type: Extensions

Price: Free

Last updated: 7/1/2019

Language: English

Product website


PHP to FileMaker Data API Made Easy

GiveItARest is a wrapper for the new Data API. Also use it as a drop in replacement for old PHP API.


The GiveItARest.php class was written with two very specific goals in mind. Primarily it is a PHP based class meant as a wrapper for the most commonly used FileMaker Data API methods. Most notably the Create, Read, Update and Delete based actions. During the initial development phase of this class, several obvious issues jumped out at us such as how to best manage the Authentication Token and, how difficult is it going to be to update a site, previously written using the FileMaker PHP API with this new class. The nexus of these two issues is what gave rise to the Secondary goal of making this class as similar to the existing FileMaker PHP API as possible.

Put as succinctly as possible, GiveItARest.php is a drop in replacement for the old FileMaker PHP API that utilized the new FileMaker Data API service (fmrest) instead of the deprecated PHP Web Publishing service (fmphp).

To use GiveItARest.php for new projects, all you need to do is load in the class:


Instantiate the class:

$fm = new GiveItARest($ServerURL,'fm_solution.fmp12', $dbStr);

And begin your CRUD operations:

$query = $fm->newFindCommand('some_fm_layout');
$query->addFindCriterion('text_field', "string");
$result = $query->execute();

To use GiveItARest.php as a drop in replacement, you'll need to look to update the following bits of old code:

Class loading and instantiation:

old code:


$fm = new FileMaker();

$fm->setProperty('database', 'fm_solution');
$fm->setProperty('hostspec', '');
$fm->setProperty('username', 'web');
$fm->setProperty('password', 'pass');

new code:


$dbStr = '[{"database": "fm_solution.fmp12", "username": "web", "password": "pass"}]';

$fm = new GiveItARest('','fm_solution.fmp12', $dbStr);

Having instantiated the class, subsequent references also need to be amended, such as:

Peering into the Error object, old code:

if (FileMaker::isError($result)) { echo "Yikes"; }

new code:

if (GiveItARest::isError($result)) { echo "Yikes"; }

And that's largely it. Using this class, you can drastically reduce the time it takes to refactor a site. This is especially important for situations where the primary reason for converting is to change the Service from fmphp to fmrest.

Additional resources

Claris product features

See why Claris products are the top choice for developers for their low code needs.

See features

Product resources

Get instant access to helpful resources and start creating custom apps today.

Get resources