PHPackages                             seunmatt/fstackapi\_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. seunmatt/fstackapi\_php

ActiveLibrary[API Development](/categories/api)

seunmatt/fstackapi\_php
=======================

This is a (Laravel) PHP wrapper for formstack's REST API v2.

1.0.1(9y ago)94.8k7[1 issues](https://github.com/SeunMatt/fstackapi_php/issues)MITPHPPHP &gt;=5.6.4

Since Jun 28Pushed 9y ago4 watchersCompare

[ Source](https://github.com/SeunMatt/fstackapi_php)[ Packagist](https://packagist.org/packages/seunmatt/fstackapi_php)[ RSS](/packages/seunmatt-fstackapi-php/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

fstackapi\_php
==============

[](#fstackapi_php)

[![Build Status](https://camo.githubusercontent.com/5dc08e126d151837659073c6032d378b320da9838779be3c5d8b06b2bc080df9/68747470733a2f2f7472617669732d63692e6f72672f5365756e4d6174742f66737461636b6170695f7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SeunMatt/fstackapi_php)

This is a convenient PHP wrapper for Formstack's REST API v2. Compatible with Laravel.

**Remember to star and watch for changes**

Installation
============

[](#installation)

`composer require seunmatt/fstackapi_php`

Laravel
-------

[](#laravel)

After installing the dependency. Add the service provider in config/app.php

```
   FormStack\Providers\FSServiceProvider::class,
```

Run `php artisan vendor:publish` to publish the config file. The config file is `formstack.php` and will be in the laravel config folder. Set your `access_token` in the config file and proceed.

Usage
=====

[](#usage)

The package is built around FormStack REST API (v2), thus it is organized in a very simple and flexible way to use. It has different classes that model the elements of Formstack API.

API Response
------------

[](#api-response)

Every JSON API Response is decoded into an assoc array and returned to the caller.

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

[](#configuration)

- If you are using this package in Laravel, just run `php artisan vendor:publish` to publish the config file `formstack.php`. As usual, it will be located in the config folder.

In the config file, provide your value for `access_token`.
The `base_url` by default is set to that of API v2.

- If you clone the repo or **are using it outside of laravel** then, create a formstack.php at the root dir of the package with the following content:

```

```

- Finally, you can put `access_token` in the environment for use. In which case, the default `base_url` will be used.

The `ConfigHelper` class will read the configuration first from the env, then try the Laravel config helper, and finally try the config file in root dir of package.

FormStack Object Instantiation
------------------------------

[](#formstack-object-instantiation)

Create an instance of the Formstack object you want to work with and then you can call the methods on the instance:

```
//using a no-arg constructor for instatiation
//assumes you have provided your access_token
//and base_url in the config file

$fsForm = new FSForm();

$fsField = new FSField();

$fsSubmision = new FSSubmission();

$fsFolder = new FSFolder();
```

**If you don't want to use the config file, You can pass the `$token` and `$baseUrl` parameter to the Formstack objects during instantiation:**

```
//initialization if no config file is provided

$token = "your-formstack-app-access-token";
$baseUrl = "https://www.formstack.com/api/v2/";

$fsForm = new FSForm($token, $baseUrl);

$fsField = new FSField($token, $baseUrl);

$fsSubmision = new FSSubmission($token, $baseUrl);

$fsFolder = new FSFolder($token, $baseUrl);
```

Example
-------

[](#example)

- **Working with forms**

```

        $fsForm = new FSForm();

        //get all forms available to the authenticated account
        // API docs - https://developers.formstack.com/docs/form-get
        $allForms = $fsForm->all();

        //create a new form
        //see the docs for other params that can be sepcified in $body
        // API docs - https://developers.formstack.com/docs/form-post
        $body = ["name" => "Created by API"];
        $newForm = $fsForm->create($body);

        $formId = $newForm["id"];

        //Getting details for a single form
        // API Docs - https://developers.formstack.com/docs/form-id-get
        $detail = $fsForm->get($formId);

        //Updating the details of a form
        // API Docs - https://developers.formstack.com/docs/form-id-put
        $updatedForm = $fsForm->update($formId, ["name" => "Updated Form Name"]);

        //Deleting a form
        // API Docs - https://developers.formstack.com/docs/form-id-delete
        $response = $fsForm->delete($formId);
```

- **Working with Fields**

```
        $fsField = new FSField();

        //Getting all fields for a form
        // API Docs - https://developers.formstack.com/docs/form-id-field-get
        $allFields = $fsField->all($formId);

        //Adding a new field to a form
        //API Doc - https://developers.formstack.com/docs/form-id-field-post
        $param = ["field_type" => "text", "label" => "Dev API Created Field"];
        $field = $fsField->newField($formId, $param);

        $fieldId = $field["id"];

        //Details of a field
        //API Doc - https://developers.formstack.com/docs/field-id-get
        $fieldDetail = $fsField->get($fieldId);

        //Updating the details of a field
        //API Doc - https://developers.formstack.com/docs/field-id-put
        $param = ["field_type" => "text", "label" => "Dev API Updated"];
        $updatedField = $fsField->update($fieldId, $param);

        //Deleting API Created field
        //API Doc - https://developers.formstack.com/docs/field-id-delete
        $response = $fsField->delete($fieldId);
```

- **Working with Submissions**

Submitting a form is straightforward but can be tricky. First get the id for all the fields of the form you want to submit to. You can do this with the FSField object (as shown above) and store the response somewhere you can reference them later.

Then you can proceed to build your data arrray and submit the form as demonstrated below.

```

        $fsSubmission = new FSSubmission();

        //Submitting to a Form
        //note that you must prefix the field id with "field_x"
        //where x is the id of the field.
        //API Doc - https://developers.formstack.com/docs/form-id-submission-post

        $data = [
            "field_0123943" => "Demo Field Value",
        ];
        $response = $fsSubmission->newSubmission($formId, $data);

        //Counting all Submissions to a Form
        //API Doc - https://developers.formstack.com/docs/form-id-submission-get

        $allSubmissions = $fsSubmission->all($formId);

        //Getting Details of a Single Submission entry
        //e.g. $submissionId = $allSubmissions["submissions"][0]["id"];
        //API Doc - https://developers.formstack.com/docs/submission-id-get

        $fsSubmission->get($submissionId);

        //Updating a Submission
        //API Doc - https://developers.formstack.com/docs/submission-id-put
        $data = [
            "field_".$fieldId => "Demo Organization Updated",
        ];
        $updatedSubmission = $fsSubmission->update($submissionId, $data);

        //Deleting a Submission
        //API Doc - https://developers.formstack.com/docs/submission-id-delete
        $fsSubmission->delete($submissionId);
```

- **Working with Folders**

```

            $fsFolder = new FSFolder();

            //All folders for the authenticated user
            //API Doc - https://developers.formstack.com/docs/folder-get
            $allFolders = $fsFolder->all();

            //create a new folder
            //API Doc - https://developers.formstack.com/docs/folder-post
            $newFolder = $fsFolder->newFolder("Dev Folder");

            //Details of a folder
            //e.g. $folderId = $newFolder["id"];
            //API Doc - https://developers.formstack.com/docs/folder-id-get
            $folderDetails = $fsFolder->get($folderId);

            //Updating a folder details
            //API Doc - https://developers.formstack.com/docs/folder-id-put
            $updatedFolder = $fsFolder->update($folderId, $newFolderName));

            //Deleting a folder
            //API Doc - https://developers.formstack.com/docs/folder-id-delete
            $delResponse = $fsFolder->delete($folderId);
```

Exceptions
----------

[](#exceptions)

You can wrap the method calls in a `try...catch` block to catch:

- `GuzzleHttp\Exception\RequestException`
- `FSExceptions\FSException`

All exceptions to API calls are caught by `GuzzleHttp\Exception\RequestException`

Tests
-----

[](#tests)

`PHPUnit` is used for testing and the test files are located in tests dir. If you fork/clone the repo and will like to run the tests.

First, ensure you have set up the config as specified above, then run the following command from the root dir of the package to run the tests.

*It will be a good idea to have an `access_token` to an account that has not reach its limit for number of forms creation.*

```
"./vendor/bin/phpunit"

```

API Components Not Covered
--------------------------

[](#api-components-not-covered)

- Partial Submissions
- Confirmation Emails
- Notification Emails
- Webhooks

Reference
=========

[](#reference)

Formstack API v2 docs:

Contributors
============

[](#contributors)

Seun Matt: on twitter [@SeunMatt2](https://twitter.com/SeunMatt2/)

Contributing
============

[](#contributing)

[READ ABOUT CONTRIBUTING HERE](CONTRIBUTING.md)

LICENSE
=======

[](#license)

[MIT](LICENSE)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3290d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a562149497a9a6d15ae506f1b940f4c914ee2dd9aa8f51cb48fb035e44b16c92?d=identicon)[seunmatt](/maintainers/seunmatt)

---

Top Contributors

[![SeunMatt](https://avatars.githubusercontent.com/u/17220297?v=4)](https://github.com/SeunMatt "SeunMatt (36 commits)")

---

Tags

phplaravelformstack

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/seunmatt-fstackapi-php/health.svg)

```
[![Health](https://phpackages.com/badges/seunmatt-fstackapi-php/health.svg)](https://phpackages.com/packages/seunmatt-fstackapi-php)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[smodav/mpesa

M-Pesa API implementation

16467.9k1](/packages/smodav-mpesa)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

783.8k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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