PHPackages                             rcconsulting/myfmapilibrary-for-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. rcconsulting/myfmapilibrary-for-php

ActiveLibrary[HTTP &amp; Networking](/categories/http)

rcconsulting/myfmapilibrary-for-php
===================================

FileMaker 17+ Data API PHP wrapper

v3.0.1(8mo ago)72621BSD-3-ClausePHPPHP &gt;=8.3.0CI failing

Since Mar 7Pushed 8mo ago3 watchersCompare

[ Source](https://github.com/rcconsulting/myFMApiLibrary-for-PHP)[ Packagist](https://packagist.org/packages/rcconsulting/myfmapilibrary-for-php)[ RSS](/packages/rcconsulting-myfmapilibrary-for-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (3)Versions (13)Used By (0)

FileMaker 17/18/19/20/21/22 Data API wrapper - myFMApiLibrary for PHP
=====================================================================

[](#filemaker-171819202122-data-api-wrapper---myfmapilibrary-for-php)

Team
----

[](#team)

[Lesterius](https://www.lesterius.com "Lesterius") is a European FileMaker Business Alliance Platinum member that operates in Belgium, France, the Netherlands, Portugal and Spain. We are creative business consultants who co-create FileMaker Platform based solutions with our customers.
Sharing knowledge takes part of our DNA, that's why we developed this library to make the FileMaker Data API easy-to-use with PHP.
Break the limits of your application!
[![Lesterius logo](https://camo.githubusercontent.com/386f3e0002c229b9c44489b4263a77571822fe7fef7e0089367dbaf43ba7698b/687474703a2f2f69312e63726561746573656e64312e636f6d2f65692f722f32392f4433332f4446462f3138333530312f637366696e616c2f4d61696c696e675f4c65737465726975732d6c6f676f2e706e67 "Lesterius")](https://camo.githubusercontent.com/386f3e0002c229b9c44489b4263a77571822fe7fef7e0089367dbaf43ba7698b/687474703a2f2f69312e63726561746573656e64312e636f6d2f65692f722f32392f4433332f4446462f3138333530312f637366696e616c2f4d61696c696e675f4c65737465726975732d6c6f676f2e706e67)

[Richard Carlton Consulting](https://rcconsulting.com/ "Richard Carlton Consulting") is a full-stack Claris FileMaker development consultancy, serving clients globally with any and all FileMaker-related needs. We also publish the largest and most [complete video training](https://fmtraining.tv/) course for the FileMaker Community.

Description
-----------

[](#description)

This library is a PHP wrapper for the Claris FileMaker Data API. It supports version 17/18/19 Data API commands, though if you use an 18 command (metadata commands for ex) on 17, it will fail.

You will be able to use every functions like it's documented in your FileMaker server Data Api documentation (accessible via https://\[your server domain\]/fmi/data/apidoc).

General FileMaker document on the FMS 17 Data API is available [here](https://help.claris.com/archive/docs/17/en/dataapi/)

General FileMaker document on the FMS 18 Data API is available [here](https://help.claris.com/archive/docs/18/en/dataapi/)

General FileMaker document on the FMS 19+ Data API is available [here](https://help.claris.com/en/data-api-guide/)

Rationale
---------

[](#rationale)

This fork is to bring greater out of the box compatibility to the myFMApiLibrary library vs the Lesterius upstream code. We're immensely grateful for the hard work Lesterius put in. Pull Requests welcome.

Requirements
------------

[](#requirements)

### Library version &lt;2.1.0:

[](#library-version-210)

- PHP &gt;= 5.5
- PHP cURL extension
- PHP mbstring extension

### Library version &gt;=2.1.0:

[](#library-version-210-1)

- PHP &gt;= 7.1
- PHP cURL extension
- PHP mbstring extension

### Library version &gt;=3.0.0:

[](#library-version-300)

- PHP &gt;= 8.3
- PHP cURL extension
- PHP mbstring extension
- Guzzle

Installation
------------

[](#installation)

The recommended way to install it is through [Composer](http://getcomposer.org).

```
composer require rcconsulting/myfmapilibrary-for-php:\>=3.0.0
```

After installing, you need to notate that you'll use this library, and require Composer's autoloader:

```
use \RCConsulting\FileMakerApi\DataApi;
require_once __DIR__ . '/vendor/autoload.php';
```

Usage
=====

[](#usage)

Prepare your FileMaker solution
-------------------------------

[](#prepare-your-filemaker-solution)

1. Enable the FileMaker Data API on your FileMaker Server Admin Console.
2. Create a user in your FileMaker database, with a custom privilege set that has at least the 'fmrest' extended privilege enabled
3. Define records &amp; layouts access for this user

Use the library
---------------

[](#use-the-library)

### Login

[](#login)

Login with credentials:

```
// Please note that the library does not currently support external data source authentication
$dataApi = new \RCConsulting\FileMakerApi\DataApi('https://test.fmconnection.com/fmi/data', 'MyDatabase');
$dataApi->login('filemaker api user', 'filemaker api password');
```

One-line example of Login with Credentials and all Options:

```
// Arguments: DAPI URL, Database Name, DAPI User, DAPI Password, SSL Verification Enabled?, Force Legacy HTTP 1.1?, Return Response Object?, HTTP Client Type?, Data API Version?
$dataApi = new \RCConsulting\FileMakerApi\DataApi('https://test.fmconnection.com/fmi/data','MyDatabase', "DAP_User", "DAPI_Pass_1234~", True, False, False, HttpClient::CURL, DapiVersion::V1);
```

Login with oauth:

```
// Please note that RCC has not tested OAuth logins. We welcome any PR's which improve support.
$dataApi = new \RCConsulting\FileMakerApi\DataApi('https://test.fmconnection.com/fmi/data', 'MyDatabase');
$dataApi->loginOauth('oAuthRequestId', 'oAuthIdentifier');
```

### Logout

[](#logout)

```
// It is highly recommended to log out at each script or large process end. The Data API tokens last 15 minutes after last use, and so will hold a slot open for 15 minutes after your last connection if you do not clean up after yourself. Additionally, logout() does not destroy the DataAPI object you created (via new) previously, but it does clean out any authorization tokens from the object.

$dataApi->logout();
```

### HTTP Client Options

[](#http-client-options)

The library supports multiple HTTP client implementations through an abstraction layer. You can choose between cURL-based and Guzzle-based HTTP clients using either type-safe enumerations or backward-compatible strings.

#### Available HTTP Clients

[](#available-http-clients)

**CurlClient (Default)**

- Uses PHP's native cURL extension
- Lightweight and fast
- Default choice for backward compatibility

**GuzzleClient**

- Uses the Guzzle HTTP client library
- Better HTTP/2 support
- Advanced features like middleware support
- Better error handling and debugging capabilities

#### Usage Examples

[](#usage-examples)

**Using HttpClientType Enumeration (Recommended):**

```
use RCConsulting\FileMakerApi\DataApi;

// Using DataApi\HttpClientType::CURL (default)
$dataApi = new DataApi(
    'https://test.fmconnection.com/fmi/data',
    'MyDatabase',
    'username',
    'password',
    true,                       // SSL verification
    false,                      // Force legacy HTTP
    false,                      // Return response object
    HttpClient::CURL,           // HTTP client type (enum)
    DapiVersion::V1             // Data API version (enum)
);

// Using DataApi\HttpClientType::GUZZLE
$dataApi = new DataApi(
    'https://test.fmconnection.com/fmi/data',
    'MyDatabase',
    'username',
    'password',
    true,                       // SSL verification
    false,                      // Force legacy HTTP
    false,                      // Return response object
    HttpClient::GUZZLE,         // HTTP client type (enum)
    DapiVersion::VLATEST        // Data API version (enum)
);

// Default behavior (uses HttpClientType::CURL)
$dataApi = new DataApi(
    'https://test.fmconnection.com/fmi/data',
    'MyDatabase',
    'username',
    'password'
);
```

**Using String Values (Backward Compatibility):**

```
// Using string 'curl'
$dataApi = new DataApi(
    'https://test.fmconnection.com/fmi/data',
    'MyDatabase',
    'username',
    'password',
    true,               // SSL verification
    false,              // Force legacy HTTP
    false,              // Return response object
    'curl',             // HTTP client type (string)
    DapiVersion::V1     // Data API version (enum)
);

// Using string 'guzzle'
$dataApi = new DataApi(
    'https://test.fmconnection.com/fmi/data',
    'MyDatabase',
    'username',
    'password',
    true,               // SSL verification
    false,              // Force legacy HTTP
    false,              // Return response object
    'guzzle',           // HTTP client type (string)
    DapiVersion::V1     // Data API version (enum)
);
```

**Constructor Parameters:**

```
new DataApi(
    string $apiUrl,                                     // FileMaker Data API URL
    string $apiDatabase,                                // Database name
    string $apiUser = null,                             // Username (optional)
    string $apiPassword = null,                         // Password (optional)
    bool $sslVerify = true,                             // Verify SSL certificates
    bool $forceLegacyHTTP = false,                      // Force HTTP/1.1
    bool $returnResponseObject = false,                 // Return full response objects
    HttpClient|string $httpClient = HttpClient::CURL    // HTTP client (enum or string)
    DapiVersion $dapiVersion = DapiVersion::V1          //specify Data API version (enum) currently v1, v2 or vLatest
);
```

#### Benefits of HTTP Client Abstraction

[](#benefits-of-http-client-abstraction)

- **Flexibility**: Switch between HTTP implementations without changing your code
- **Future-proofing**: Easy migration to new HTTP client libraries
- **Testing**: Better mocking capabilities with Guzzle
- **Performance**: Choose the best client for your specific needs
- **Backward Compatibility**: Existing code continues to work unchanged

### Create record

[](#create-record)

```
// Call login method first

$recordData = [
    'FirstName'         => 'John',
    'LastName'          => 'Doe',
    'email'             => 'johndoe@acme.inc',
    'RepeatingField(1)' => 'Test'
];

$scripts = [
    [
        'name'  => 'ScriptThatRunsBeforeRequest',
        'param' => 'johndoe@acme.inc',
        'type'  => RCConsulting\FileMakerApi\DataApi::SCRIPT_PREREQUEST
    ],
    [
        'name'  => 'ScriptThatRunsAfterRequestBeforeSort',
        'param' => 'johndoe@acme.inc',
        'type'  => RCConsulting\FileMakerApi\DataApi::SCRIPT_PRESORT
    ],
    [
        'name'  => 'ScriptThatRunsAfterRequestAfterSort',
        'param' => 'johndoe@acme.inc',
        'type'  => RCConsulting\FileMakerApi\DataApi::SCRIPT_POSTREQUEST
    ]
];

$portalData = [
    'lunchDate' => '17/04/2013',
    'lunchPlace' => 'Acme Inc.'
];

try {
    $recordId = $dataApi->createRecord('layout name', $recordData, $scripts, $portalData);
} catch(\Exception $e) {
  // handle exception
}
```

### Delete record

[](#delete-record)

```
// Call login method first

try {
  $dataApi->deleteRecord('layout name', $recordId, $scripts);
} catch(\Exception $e) {
  // handle exception
}
```

### Edit record

[](#edit-record)

```
// Call login method first

try {
  $recordId = $dataApi->editRecord('layout name', $recordId, $recordData, $lastModificationId, $portalData, $scripts);
} catch(\Exception $e) {
  // handle exception
}
```

### Get record

[](#get-record)

```
// Call login method first

$portals = [
    [
        'name'   => 'Portal1',
        'limit'  => 10
    ],
    [
        'name'   => 'Portal2',
        'offset' => 3
    ]
];

try {
  $record = $dataApi->getRecord('layout name', $recordId, $portals, $scripts, $responseLayout, $dateFormat);
} catch(\Exception $e) {
  // handle exception
}
```

### Get records

[](#get-records)

```
// Call login method first

$sort = [
    [
        'fieldName' => 'FirstName',
        'sortOrder' => 'ascend'
    ],
    [
        'fieldName' => 'City',
        'sortOrder' => 'descend'
    ]
];

try {
  $record = $dataApi->getRecords('layout name', $sort, $offset, $limit, $portals, $scripts, $responseLayout, $dateFormat);
} catch(\Exception $e) {
  // handle exception
}
```

### Find records

[](#find-records)

```
// Call login method first
$query = [
    [
        'fields'  => [
            ['fieldname' => 'FirstName', 'fieldvalue' => '==Test'],
            ['fieldname' => 'LastName', 'fieldvalue' => '==Test'],
        ],
        'options' => [
            'omit' => false
        ]
    ]
];

try {
  $results = $dataApi->findRecords('layout name', $query, $sort, $offset, $limit, $portals, $scripts, $responseLayout, $dateFormat);
} catch(\Exception $e) {
  // handle exception
}
```

### Blind Fire Script

[](#blind-fire-script)

```
try {
    $dataApi->executeScript($layout, $scriptName, $scriptParameters);
} catch(\Exception $e) {
    // handle exception
}
```

### Set global fields

[](#set-global-fields)

```
// Call login method first

$globalsData = [
  'FieldName1'	=> 'value',
  'FieldName2'	=> 'value'
];

try {
  $dataApi->setGlobalFields('layout name', $globalsData);
} catch(\Exception $e) {
  // handle exception
}
```

### Upload file to container

[](#upload-file-to-container)

#### File Passed Via WebForm

[](#file-passed-via-webform)

```
// Call login method first

$containerFieldName       = 'Picture';
$containerFieldRepetition = 1;
// replace 'upload' below with the name="value" of the file input element of your web form
$filepath                 = $_FILES['upload']['tmp_name'];
$filename                 = $_FILES['upload']['name'];

try {
  $dataApi->uploadToContainer('layout name', $recordId, $containerFieldName, $containerFieldRepetition, $filepath, $filename);
} catch(\Exception $e) {
  // handle exception
}
```

#### File On Server

[](#file-on-server)

```
// Call login method first

$containerFieldName       = 'Picture';
$containerFieldRepetition = 1;
$filepath                 = '/usr/home/acme/pictures/photo.jpg';

try {
  $dataApi->uploadToContainer('layout name', $recordId, $containerFieldName, $containerFieldRepetition, $filepath);
} catch(\Exception $e) {
  // handle exception
}
```

library helper methods
----------------------

[](#library-helper-methods)

#### token usage

[](#token-usage)

FileMaker Data API session tokens last 15 minutes from last use. By default, this library will manage them for you. If you use the login() methods, the library will log in again automatically to retreive a new token if the one you are using has expired.

This allows easy management, and separation by user, database, or privilege set. You can easily separate different data sets, databases, or privileged access views by launching (`new`) and managing multiple data api objects at once.

If you wish to manage these session tokens directly, you can use the methods below.

```
// useful when not explicitly logging into data api, but already have valid session token
// this implicitly sets the token retrieval date to now()
$dataApi->setApiToken($token);
// here, $tokenDate is a unix timestamp
$dataApi->setApiToken($token, $tokenDate);

// returns current api token (without checking if it's valid)
$token = $dataApi->getApiToken();

// check if token is expired using previously-stored last use-date
// this is NOT a live check with FMS
if ($dataApi->isApiTokenExpired()) {
// token expired
} else {
// do stuff
}

// refresh token when it has expired
// this logs in again, which creates a new session, so should only be used after the previous token has expired
// you must have used the login() method previously. oAuth not tested.
if ($dataApi->refreshToken()) {
// success
} else {
// failure - either the login itself failed, or you have no stored credentials
}

// check if the session token we are using is valid according to FileMaker Server
if ($dataApi->validateTokenWithServer()){
// token is valid according to FMS!
} else {
// token has expired according to FMS!
}
```

#### update object settings

[](#update-object-settings)

```
//use this if you need to explicitly use v1 or v2. The default is v1, any future versions will be added. vLatest is also supported.
$dataApi->setDAPIVersion(DapiVersion::V2)
```

ToDo:
-----

[](#todo)

- replace all curl with [guzzle](https://github.com/guzzle/guzzle "GuzzleHTTP"), while adding [certainty](https://github.com/paragonie/certainty "Certainty") and [monolog](https://github.com/Seldaek/monolog "monolog")

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance59

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 74.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~268 days

Recently: every ~432 days

Total

10

Last Release

258d ago

Major Versions

1.1.6 → 2.0.02019-12-20

2.1.0 → 3.0.02025-09-17

PHP version history (3 changes)1.0.0PHP &gt;=5.5.0

2.1.0PHP &gt;=7.1.0

3.0.0PHP &gt;=8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/41a866e391c53522b888aa34f5101715edf7693003558e2315a59c5ffc23b114?d=identicon)[JacobTaylor-RCC](/maintainers/JacobTaylor-RCC)

---

Top Contributors

[![JacobTaylor-RCC](https://avatars.githubusercontent.com/u/39351909?v=4)](https://github.com/JacobTaylor-RCC "JacobTaylor-RCC (100 commits)")[![joneisen](https://avatars.githubusercontent.com/u/34011767?v=4)](https://github.com/joneisen "joneisen (21 commits)")[![lguilbert](https://avatars.githubusercontent.com/u/39915415?v=4)](https://github.com/lguilbert "lguilbert (11 commits)")[![qodana-bot](https://avatars.githubusercontent.com/u/139879315?v=4)](https://github.com/qodana-bot "qodana-bot (2 commits)")

---

Tags

apirestdatabasewrapperFileMakerdata apiclaris

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rcconsulting-myfmapilibrary-for-php/health.svg)

```
[![Health](https://phpackages.com/badges/rcconsulting-myfmapilibrary-for-php/health.svg)](https://phpackages.com/packages/rcconsulting-myfmapilibrary-for-php)
```

###  Alternatives

[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.6M18](/packages/xeroapi-xero-php-oauth2)[dreamfactory/df-core

DreamFactory(tm) Core Components

1652.0k38](/packages/dreamfactory-df-core)[zenditplatform/zendit-php-sdk

PHP client for Zendit API

1194.4k](/packages/zenditplatform-zendit-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
