PHPackages                             kylewlawrence/gravity-forms-laravel - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kylewlawrence/gravity-forms-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kylewlawrence/gravity-forms-laravel
===================================

Laravel wrapper for kylewlawrence/gravity-forms-api-client-php package

066↓100%PHP

Since Apr 20Pushed 3y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel GForms
==============

[](#laravel-gforms)

This package provides integration with the GForms API. It supports creating forms, retrieving and updating entries, sending notifications, etc.

The package simply provides a `GForms` facade that acts as a wrapper to the [kylewlawrence/gravity-forms-api-client-php](https://github.com/kylewlawrence/gravity-forms-api-client-php) package.

**NB:** Currently only supports bearer token-based authentication.

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

[](#installation)

You can install this package via Composer using:

```
composer require kylewlawrence/gravity-forms-laravel
```

The Facade is automatically installed with the alias `GForms`

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

[](#configuration)

To publish the config file to `app/config/gravity-forms-laravel.php` run:

```
php artisan vendor:publish --provider="KyleWLawrence\GForms\Providers\GFormsServiceProvider"
```

Set your configuration using **environment variables**, either in your `.env` file or on your server's control panel:

- `GF_USERNAME`

The API username. You can create one in your Gravity Forms Settings

- `GF_PASSWORD`

The API password.

- `GF_DOMAIN`

The domain and path of the website with Gravity Forms. Only the domain and path, not the protocol should be passed. forms.example.com should be passed for

- `GF_DRIVER` *(Optional)*

Set this to `null` or `log` to prevent calling the GForms API directly from your environment.

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

[](#contributing)

If you have any questions/problems/request with the SDK (the GFormsService class), please go to the [GForms PHP SDK repository](https://github.com/KyleWLawrence/gravity-forms-api-client-php) with those requests. Pull Requests for the Laravel wrapper are always welcome here. I'll catch-up and develop the contribution guidelines soon. For the meantime, just open and issue or create a pull request.

Usage
-----

[](#usage)

### Facade

[](#facade)

The `GForms` facade acts as a wrapper for an instance of the `GForms\API\Client` class. Any methods available on this class ([documentation here](https://github.com/kylewlawrence/gravity-forms-api-client-php#usage)) are available through the facade. for example:

```
// 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);

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

### Dependency injection

[](#dependency-injection)

If you'd prefer not to use the facade, you can skip adding the alias to `config/app.php` and instead inject `KyleWLawrence\GForms\Services\GFormsService` into your class. You can then use all of the same methods on this object as you would on the facade.

```
