Laravel wrapper for kylewlawrence/gravity-forms-api-client-php package
kylewlawrence/gravity-forms-laravel is a Laravel package for laravel wrapper for kylewlawrence/gravity-forms-api-client-php package.
It currently has 0 GitHub stars and 71 downloads on Packagist.
Install it with composer require kylewlawrence/gravity-forms-laravel.
Discover more Laravel packages by kylewlawrence
or browse all Laravel packages to compare alternatives.
Last updated
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 package.
NB: Currently only supports bearer token-based authentication.
You can install this package via Composer using:
composer require kylewlawrence/gravity-forms-laravel
The Facade is automatically installed with the alias GForms
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_USERNAMEThe API username. You can create one in your Gravity Forms Settings
GF_PASSWORDThe API password.
GF_DOMAINThe 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 https://forms.example.com
GF_DRIVER (Optional)Set this to null or log to prevent calling the GForms API directly from your environment.
If you have any questions/problems/request with the SDK (the GFormsService class), please go to the GForms PHP SDK repository 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.
The GForms facade acts as a wrapper for an instance of the GForms\API\Client class. Any methods available on this class (documentation here) 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);
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.
<?php
use KyleWLawrence\GForms\Services\GFormsService;
class MyClass {
public function __construct(GFormsService $gforms_service) {
$this->gforms_service = $gforms_service;
}
public function getSite() {
$this->gforms_service->site()->get(12345);
}
}
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
http://www.apache.org/licenses/LICENSE-2.0
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.