Download the PHP package spinen/laravel-formio without Composer
On this page you can find all versions of the php package spinen/laravel-formio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-formio
SPINEN's Laravel Formio
PHP package to interface with Formio
We solely use Laravel 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
| Branch | Status | Coverage | Code Quality |
|---|---|---|---|
| Develop | ![]() |
![]() |
|
| Master | ![]() |
![]() |
Installation
Install Formio PHP Package:
The package uses the auto registration feature of Laravel.
Usage
The primary class is Spinen\Formio\Client. It gets constructed with 3 parameters...
-
array $config- Configuration properties. See theformio.phpfile in the./configdirectory for a documented list of options. -
Guzzle $guzzle- Instance ofGuzzleHttp\Client Token $token- [Optional] Instance ofSpinen\Formio\Token
Once you new up a Client instance, you have the following methods...
-
addUser(FormioUser $user, $password = null)- Add the user to theuserresource 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 theformio_passwordproperty of the$userobject, and thesavemethod 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$useris provided, then log the user into Formio with the array provided by thegetLoginDatamethod on the$userobject. Otherwise, log in the admin user from the config. -
logout()- Null the$token -
request($path, $data = [], $method = 'GET')- Make an API call to Formio to$pathwith the$datausing the JWT for the logged in user. -
setConfigs(array $configs)- Allow overriding the$configson theClientinstance. -
sso(FormioUser $user)- If the$userinstance has a value set forformio_passwordproperty, then get a JWT from Formio via API. Otherwise, generate a Custom JWT for the user. uri($path = null)- Generate a full uri for the path on the Formio server.
Laravel
Configuration
-
You will need to make your
Userobject implementSpinen\Formio\Contracts\FormioUserso that it will have the required methods. We have also included theSpinen\Formio\Concerns\HasFormstrait which will satisfy the contract. -
Add the appropriate values to your
Minimal Keys
Optional Keys
-
[Optional] Publish config & migration
Config
A configuration file named can be published to by running...
Migration
Migrations files can be published by running...
JS API
By default, there is a route published at /api/formio/jwt which is behind the api & auth:api middlewares, so from your js code, you can request a JWT for the authenticated user from the route...
to get a payload like this...
Examples
Here is an example of getting the roles as admin:
Here is an example of getting the form names as a user with a custom JWT:
Generic PHP
Examples
Here is an example of getting the current user as admin:
All versions of laravel-formio with dependencies
firebase/php-jwt Version ^5.0
guzzlehttp/guzzle Version ^7.4.5
laravel/framework Version ^8|^9|^10
laravel/pint Version ^1.6
nesbot/carbon Version ^2.62.1
vlucas/phpdotenv Version ^5.0



