PHPackages                             spinen/laravel-formio - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. spinen/laravel-formio

AbandonedArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

spinen/laravel-formio
=====================

SPINEN's Laravel Package for Formio.

1.1.0(3y ago)62.1k1[1 issues](https://github.com/spinen/laravel-formio/issues)MITPHPPHP &gt;=8.1

Since Oct 4Pushed 3y ago7 watchersCompare

[ Source](https://github.com/spinen/laravel-formio)[ Packagist](https://packagist.org/packages/spinen/laravel-formio)[ RSS](/packages/spinen-laravel-formio/feed)WikiDiscussions develop Synced today

READMEChangelog (2)Dependencies (9)Versions (16)Used By (0)

SPINEN's Laravel Formio
=======================

[](#spinens-laravel-formio)

[![Latest Stable Version](https://camo.githubusercontent.com/27268fa7a22b8d56cfb0e13a880b9e21fdf115c4f858185db9a753f54479ba6b/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d666f726d696f2f762f737461626c65)](https://packagist.org/packages/spinen/laravel-formio)[![Latest Unstable Version](https://camo.githubusercontent.com/1c803cbe0e0af07a93f535bca856f5a303ab9838c3a8f098baac53883cdce0d0/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d666f726d696f2f762f756e737461626c65)](https://packagist.org/packages/spinen/laravel-formio)[![Total Downloads](https://camo.githubusercontent.com/d27ab2361006cc970576b88f30efb83b5e108412f3f9dfe85b98e25df578319a/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d666f726d696f2f646f776e6c6f616473)](https://packagist.org/packages/spinen/laravel-formio)[![License](https://camo.githubusercontent.com/ebcde20d0c20a3c76576123381c63807d3a88135af1fb57ca983a274c8389fce/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d666f726d696f2f6c6963656e7365)](https://packagist.org/packages/spinen/laravel-formio)

PHP package to interface with [Formio](https://www.form.io)

We solely use [Laravel](https://www.laravel.com) for our applications, so this package is written with Laravel in mind. We have tried to make it work outside of Laravel. If there is a request from the community to split this package into 2 parts, then we will consider doing that work.

Build Status
------------

[](#build-status)

BranchStatusCoverageCode QualityDevelop[![Build Status](https://camo.githubusercontent.com/adb4f2d3735b234c3fc733ffb33bf06e61eb980d2cadee7bdc734f253d958648/68747470733a2f2f7472617669732d63692e6f72672f7370696e656e2f6c61726176656c2d666f726d696f2e7376673f6272616e63683d646576656c6f70)](https://github.com/spinen/laravel-formio/workflows/CI/badge.svg?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/91c541b2877dd4efc8b54460a60854fd186adf505045a76a9e24af347d2b2240/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d666f726d696f2f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/spinen/laravel-formio/?branch=develop)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/67a190f9bfe44f0890b63fc7ff7882d278540e7379a4cf1d67a17b44e7be66ef/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d666f726d696f2f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/spinen/laravel-formio/?branch=develop)Master[![Build Status](https://github.com/spinen/laravel-formio/workflows/CI/badge.svg?branch=master)](https://github.com/spinen/laravel-formio/workflows/CI/badge.svg?branch=master)[![Code Coverage](https://camo.githubusercontent.com/3a0bf5975472f0995d28e8eaba3416b84a8f98f96f40f15b2602ef182d83d14d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d666f726d696f2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spinen/laravel-formio/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e2cda2e03ba61c9a3466355df75e520131a23ad16eb795eed392af728d232420/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d666f726d696f2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spinen/laravel-formio/?branch=master)Installation
------------

[](#installation)

Install Formio PHP Package:

```
$ composer require spinen/laravel-formio
```

The package uses the [auto registration feature](https://laravel.com/docs/master/packages#package-discovery) of Laravel.

Usage
-----

[](#usage)

The primary class is `Spinen\Formio\Client`. It gets constructed with 3 parameters...

- `array $config` - Configuration properties. See the `formio.php` file in the `./config` directory for a documented list of options.
- `Guzzle $guzzle` - Instance of `GuzzleHttp\Client`
- `Token $token` - *\[Optional\]* Instance of `Spinen\Formio\Token`

Once you new up a `Client` instance, you have the following methods...

- `addUser(FormioUser $user, $password = null)` - Add the user to the `user` resource in Formio. If no password is provided, then if a default password is specified in the config, it is used. Otherwise, generate a random 32 character string. Once the user is added to Formio, then the password is set on the `formio_password` property of the `$user` object, and the `save` method is called on it to persist the password for future interactions with Formio for the user. Finally, set the user's JWT on the `$token`, so that requests are made via the user.
- `login(FormioUser $user = null)` - If a `$user` is provided, then log the user into Formio with the array provided by the `getLoginData` method on the `$user` object. Otherwise, log in the admin user from the config.
- `logout()` - Null the `$token`
- `request($path, $data = [], $method = 'GET')` - Make an [API](https://help.form.io/developer/api/) call to Formio to `$path` with the `$data` using the JWT for the logged in user.
- `setConfigs(array $configs)` - Allow overriding the `$configs` on the `Client` instance.
- `sso(FormioUser $user)` - If the `$user` instance has a value set for `formio_password` property, then get a JWT from Formio via API. Otherwise, generate a [Custom JWT](https://help.form.io/integrations/sso/) for the user.
- `uri($path = null)` - Generate a full uri for the path on the Formio server.

Laravel
-------

[](#laravel)

### Configuration

[](#configuration)

1. You will need to make your `User` object implement `Spinen\Formio\Contracts\FormioUser` so that it will have the required methods. We have also included the `Spinen\Formio\Concerns\HasForms` trait which will satisfy the contract.

    ```
