PHPackages                             kylewlawrence/gravity-forms-api-client-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. [API Development](/categories/api)
4. /
5. kylewlawrence/gravity-forms-api-client-php

ActiveLibrary[API Development](/categories/api)

kylewlawrence/gravity-forms-api-client-php
==========================================

GForms API PHP SDK

173↓100%PHP

Since Apr 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/KyleWLawrence/gravity-forms-api-client-php)[ Packagist](https://packagist.org/packages/kylewlawrence/gravity-forms-api-client-php)[ RSS](/packages/kylewlawrence-gravity-forms-api-client-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

GForms API PHP SDK Client Library
=================================

[](#gforms-api-php-sdk-client-library)

API Client Version
------------------

[](#api-client-version)

This is the first version of a community sponsored PHP SDK client for Gravity Forms API.

API version support
-------------------

[](#api-version-support)

This client **only** supports Gravity Forms's API v2. Please see their [API documentation](https://docs.gravityforms.com/rest-api-v2/) for more information.

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

[](#requirements)

- PHP 8.1+

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

[](#installation)

The Gravity Forms API PHP SDK client can be installed using [Composer](https://packagist.org/packages/kylewlawrence/gravity-forms-api-client-php).

Are you using this with Laravel? If so, use the [Laravel wrapper](https://github.com/KyleWLawrence/gravity-forms-laravel).

### Composer

[](#composer)

To install run `composer require kylewlawrence/gravity-forms-api-client-php`

Configuration
-------------

[](#configuration)

Configuration is done through an instance of `GForms\Api\HttpClient`. The block is mandatory and if not passed, an error will be thrown.

```
// load Composer
require 'vendor/autoload.php';

use KyleWLawrence\GForms\Api\HttpClient as GFormsAPI;

$username     = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv"; // replace this with your Gravity Forms api username
$password     = "fdsJfds43dMo1mRDMuVwkw1EPsNkeUj9fdjk376l"; // replace this with your Gravity Forms api password
$domain       = "example.com"; // replace this with the domain (and path) of your Gravity Forms installation

$client = new GFormsAPI();
$client->setAuth('basic', ['username' => $username, 'password' => $password]);
```

Usage
-----

[](#usage)

### Basic Operations

[](#basic-operations)

```
// Get all forms
$forms = $client->forms()->getAll();
print_r($forms);

// Create a new form
$newForm = $client->forms()->create([
    'title' => 'Blah Blah',
    'fields' => [
        {
            'id' : '1',
            'label' : 'My Text',
            'type' : 'text'
        },
        {
            'id' : '2',
            'label' : 'More Text',
            'type' : 'text'
        }
    ],
]);
print_r($newForm);

// Update a form
$client->forms()->update(12345, [
    'title' => 'New Title',
    'fields' => [
        {
            'id' : '1',
            'label' : 'New Field Label',
            'type' : 'text'
        },
        {
            'id' : '2',
            'label' : 'New Field Label #2',
            'type' : 'text'
        }
    ],
]);

// Delete a form
$client->forms()->delete(12345);

// Get all forms
$forms = $client->forms()->getAll();
print_r($forms);
```

Discovering Methods &amp; Classes
---------------------------------

[](#discovering-methods--classes)

```
// Get the base methods/classes available
$client->getValidSubResrouces()

// The above example will output something like:
[
    'entries' => "GForms\Api\Resources\Core\Entries",
    'forms' => "GForms\Api\Resources\Core\Forms",
]

// These are methods/classes that can be chained to the client. For instance:
// For instance, "forms" => "GForms\Api\Resources\Core\Forms", can be used as $client->forms()

// To find the chained methods available to the class, now do:
$client->forms()->getRoutes()

// The above example will output something like:
[
    'getAll' => 'forms',
    'get' => 'forms/{id}',
    'create' => 'forms',
    'update' => 'forms/{id}',
    'delete' => 'forms/{id}',
]

// Those routes can be compared with the GForms documentation routes and run as chained methods such as the below command to get all sites:
$client->forms()->getAll()
```

### Pagination

[](#pagination)

The GForms API offers a way to get the next pages for the requests and is documented in [the GForms Developer Documentation](https://docs.gravityforms.com/rest-api-v2/#h-use-paging).

The way to do this is to pass it as an option to your request.

```
$forms = $this->client->forms()->getAll(['paging[page_size]' => 20, 'paging[current_page]' => 1]);
```

The allowed options are

- page\_size
- current\_page
- offset

### Retrying Requests

[](#retrying-requests)

Add the `RetryHandler` middleware on the `HandlerStack` of your `GuzzleHttp\Client` instance. By default `GForms\Api\HttpClient`retries:

- timeout requests
- those that throw `Psr\Http\Message\RequestInterface\ConnectException:class`
- and those that throw `Psr\Http\Message\RequestInterface\RequestException:class` that are identified as ssl issue.

#### Available options

[](#available-options)

Options are passed on `RetryHandler` as an array of values.

- max = 2 *limit of retries*
- interval = 300 *base delay between retries in milliseconds*
- max\_interval = 20000 *maximum delay value*
- backoff\_factor = 1 *backoff factor*
- exceptions = \[ConnectException::class\] *Exceptions to retry without checking retry\_if*
- retry\_if = null *callable function that can decide whether to retry the request or not*

Contributing
------------

[](#contributing)

Pull Requests are always welcome. I'll catch-up and develop the contribution guidelines soon. For the meantime, just open and issue or create a pull request.

Copyright and license
---------------------

[](#copyright-and-license)

Copyright 2023-present KyleWLawrence

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c451791102de0a70927f6545c5c1a75d444975e3077c3c7b4b6eaa4db5229d4?d=identicon)[KyleWLawrence](/maintainers/KyleWLawrence)

---

Top Contributors

[![KyleWLawrence](https://avatars.githubusercontent.com/u/10180771?v=4)](https://github.com/KyleWLawrence "KyleWLawrence (5 commits)")

### Embed Badge

![Health badge](/badges/kylewlawrence-gravity-forms-api-client-php/health.svg)

```
[![Health](https://phpackages.com/badges/kylewlawrence-gravity-forms-api-client-php/health.svg)](https://phpackages.com/packages/kylewlawrence-gravity-forms-api-client-php)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M186](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M33](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

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