{"id":37005816,"url":"https://github.com/spinen/laravel-formio","last_synced_at":"2026-01-14T00:41:11.007Z","repository":{"id":35146740,"uuid":"212716809","full_name":"spinen/laravel-formio","owner":"spinen","description":"SPINEN's Laravel Package for Formio.","archived":true,"fork":false,"pushed_at":"2023-03-18T02:26:51.000Z","size":53,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":7,"default_branch":"develop","last_synced_at":"2025-10-22T05:54:37.206Z","etag":null,"topics":["api","api-client","client","custom-jwt","formio","jwt","laravel","php","spinen"],"latest_commit_sha":null,"homepage":"https://spinen.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spinen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-04T01:50:24.000Z","updated_at":"2024-04-08T12:01:25.000Z","dependencies_parsed_at":"2022-07-25T19:17:28.619Z","dependency_job_id":null,"html_url":"https://github.com/spinen/laravel-formio","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/spinen/laravel-formio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinen%2Flaravel-formio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinen%2Flaravel-formio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinen%2Flaravel-formio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinen%2Flaravel-formio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spinen","download_url":"https://codeload.github.com/spinen/laravel-formio/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinen%2Flaravel-formio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","client","custom-jwt","formio","jwt","laravel","php","spinen"],"created_at":"2026-01-14T00:41:10.918Z","updated_at":"2026-01-14T00:41:10.988Z","avatar_url":"https://github.com/spinen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SPINEN's Laravel Formio\n\n[![Latest Stable Version](https://poser.pugx.org/spinen/laravel-formio/v/stable)](https://packagist.org/packages/spinen/laravel-formio)\n[![Latest Unstable Version](https://poser.pugx.org/spinen/laravel-formio/v/unstable)](https://packagist.org/packages/spinen/laravel-formio)\n[![Total Downloads](https://poser.pugx.org/spinen/laravel-formio/downloads)](https://packagist.org/packages/spinen/laravel-formio)\n[![License](https://poser.pugx.org/spinen/laravel-formio/license)](https://packagist.org/packages/spinen/laravel-formio)\n\nPHP package to interface with [Formio](https://www.form.io)\n\nWe 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.\n\n## Build Status\n\n| Branch | Status | Coverage | Code Quality |\n| ------ | :----: | :------: | :----------: |\n| Develop | [![Build Status](https://travis-ci.org/spinen/laravel-formio.svg?branch=develop)](https://github.com/spinen/laravel-formio/workflows/CI/badge.svg?branch=develop) | [![Code Coverage](https://scrutinizer-ci.com/g/spinen/laravel-formio/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/spinen/laravel-formio/?branch=develop) | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spinen/laravel-formio/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/spinen/laravel-formio/?branch=develop) |\n| 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://scrutinizer-ci.com/g/spinen/laravel-formio/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/spinen/laravel-formio/?branch=master) | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spinen/laravel-formio/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/spinen/laravel-formio/?branch=master) |\n\n## Installation\n\nInstall Formio PHP Package:\n\n```bash\n$ composer require spinen/laravel-formio\n```\n\nThe package uses the [auto registration feature](https://laravel.com/docs/master/packages#package-discovery) of Laravel.\n\n## Usage\n\nThe primary class is `Spinen\\Formio\\Client`.  It gets constructed with 3 parameters...\n\n* `array $config` - Configuration properties.  See the `formio.php` file in the `./config` directory for a documented list of options.\n\n* `Guzzle $guzzle` - Instance of `GuzzleHttp\\Client`\n\n* `Token $token` - _[Optional]_ Instance of `Spinen\\Formio\\Token`\n\nOnce you new up a `Client` instance, you have the following methods...\n\n* `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.\n\n* `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.\n\n* `logout()` - Null the `$token`\n\n* `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.\n\n* `setConfigs(array $configs)` - Allow overriding the `$configs` on the `Client` instance.\n\n* `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.\n\n* `uri($path = null)` - Generate a full uri for the path on the Formio server.\n\n\n## Laravel\n\n### Configuration\n\n1. 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.\n\n    ```php\n    \u003c?php\n\n    namespace App;\n\n    use Illuminate\\Contracts\\Auth\\MustVerifyEmail;\n    use Illuminate\\Foundation\\Auth\\User as Authenticatable;\n    use Illuminate\\Notifications\\Notifiable;\n    use Spinen\\Formio\\Concerns\\HasForms;\n    use Spinen\\Formio\\Contracts\\FormioUser;\n\n    class User extends Authenticatable implements FormioUser\n    {\n        use FormioUser, Notifiable;\n\n        // ...\n    }\n    ```\n\n2. Add the appropriate values to your ```.env```\n\n    #### Minimal Keys\n\n    ```bash\n    FORMIO_ADMIN_PASSWORD=\u003cadmin password in formio\u003e\n    FORMIO_ADMIN_USERNAME=\u003cadmin username in formio\u003e\n    FORMIO_URL=\u003curl to formio\u003e\n    ```\n\n    #### Optional Keys\n    ```bash\n    FORMIO_JWT_ALGORITHM=\u003cjwt algorithm\u003e                   # Default: HS256\n    FORMIO_JWT_SECRET=\u003cjwt secret\u003e                         # Default: --- change me now --- (same as docker image)\n    FORMIO_PROJECT_ID=\u003cproject id\u003e                         # Default: null\n    FORMIO_USER_FORM=\u003cid of the user resource\u003e             # Default: null (Will lookup the id for \"user\" if null)\n    FORMIO_USER_ROLES=\u003ccomma seperated list of user roles\u003e # Default: null (Will lookup Authenticated if null)\n    ```\n\n3. _[Optional]_ Publish config \u0026 migration\n\n    #### Config\n    A configuration file named ```formio.php``` can be published to ```config/``` by running...\n\n    ```bash\n    php artisan vendor:publish --tag=formio-config\n    ```\n\n    #### Migration\n    Migrations files can be published by running...\n\n    ```bash\n    php artisan vendor:publish --tag=formio-migrations\n    ```\n\n### JS API\n\nBy default, there is a route published at `/api/formio/jwt` which is behind the `api` \u0026 `auth:api` middlewares, so from your js code, you can request a JWT for the authenticated user from the route...\n\n```js\naxios.get('/api/formio/jwt')\n    .then(({ data: { data: { expires_at, jwt } } }) =\u003e {\n        this.jwt = jwt;\n        this.jwt_expires_at = expires_at;\n\n        // Do something with the form like Formio.setToken(jwt)\n    })\n    .catch((e) =\u003e {\n        this.errors.push(e);\n    });\n```\n\nto get a payload like this...\n\n```json\n{\n    \"data\": {\n        \"expires_at\": \"2019-10-04T20:29:58+00:00\",\n        \"jwt\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHRlcm5hbCI6dHJ1ZSwiZm9ybSI6eyJfaWQiOiI1ZDkxNmIyNjBlYTBjNzAwMWE4ZWVlM2MifSwidXNlciI6eyJfaWQiOiJleHRlcm5hbCIsImRhdGEiOnsiZW1haWwiOiJvamFjb2JzQGV4YW1wbGUub3JnIiwiZmlyc3ROYW1lIjoiQXJ2aWQiLCJsYXN0TmFtZSI6IlJ1ZWNrZXIifSwicm9sZXMiOlsiNWQ5MTZiMjYwZWEwYzcwMDFhOGVlZTNhIl19LCJpYXQiOjE1NzAxMzg3MjIsImV4cCI6MTU3MDE1MzEyMn0.ZxWTJIteHXomGz1F7yYjSJcXvWLZQZYRrPN4cKB3KAk\"\n    }\n}\n```\n\n### Examples\n\nHere is an example of getting the roles as admin:\n\n```php\n$ php artisan tinker\nPsy Shell v0.9.9 (PHP 7.2.14 — cli) by Justin Hileman\n\u003e\u003e\u003e $formio = app(Spinen\\Formio\\Client::class)\n=\u003e Spinen\\Formio\\Client {#3534\n     +token: Spinen\\Formio\\Token {#3528\n       // ...\n     },\n   }\n\u003e\u003e\u003e $formio-\u003elogin()\n=\u003e Spinen\\Formio\\Client {#3534\n     +token: Spinen\\Formio\\Token {#3528\n       // ...\n       +user: [\n         \"_id\" =\u003e \"5d916b270ea0c7001a8eee4a\",\n         \"owner\" =\u003e null,\n         \"roles\" =\u003e [\n           \"5d916b260ea0c7001a8eee39\",\n         ],\n         \"form\" =\u003e \"5d916b260ea0c7001a8eee3d\",\n         \"data\" =\u003e [\n           \"email\" =\u003e \"admin@domain.com\",\n         ],\n         // ...\n       ],\n     },\n   }\n\u003e\u003e\u003e $formio-\u003erequest('/role')\n=\u003e [\n     [\n       \"_id\" =\u003e \"5d916b260ea0c7001a8eee39\",\n       \"description\" =\u003e \"A role for Administrative Users.\",\n       \"default\" =\u003e false,\n       \"admin\" =\u003e true,\n       \"title\" =\u003e \"Administrator\",\n       \"machineName\" =\u003e \"administrator\",\n       \"created\" =\u003e \"2019-09-30T02:40:38.377Z\",\n       \"modified\" =\u003e \"2019-09-30T02:40:38.491Z\",\n     ],\n     [\n       \"_id\" =\u003e \"5d916b260ea0c7001a8eee3b\",\n       \"description\" =\u003e \"A role for Anonymous Users.\",\n       \"default\" =\u003e true,\n       \"admin\" =\u003e false,\n       \"title\" =\u003e \"Anonymous\",\n       \"machineName\" =\u003e \"anonymous\",\n       \"created\" =\u003e \"2019-09-30T02:40:38.735Z\",\n       \"modified\" =\u003e \"2019-09-30T02:40:38.737Z\",\n     ],\n     [\n       \"_id\" =\u003e \"5d916b260ea0c7001a8eee3a\",\n       \"description\" =\u003e \"A role for Authenticated Users.\",\n       \"default\" =\u003e false,\n       \"admin\" =\u003e false,\n       \"title\" =\u003e \"Authenticated\",\n       \"machineName\" =\u003e \"authenticated\",\n       \"created\" =\u003e \"2019-09-30T02:40:38.648Z\",\n       \"modified\" =\u003e \"2019-09-30T02:40:38.682Z\",\n     ],\n   ]\n\u003e\u003e\u003e\n```\n\nHere is an example of getting the form names as a user with a custom JWT:\n\n```php\n$ php artisan tinker\n\u003e\u003e\u003e $user = factory(App\\User::class)-\u003ecreate()\n=\u003e App\\User {#3565\n     first_name: \"Arvid\",\n     last_name: \"Ruecker\",\n     email: \"ojacobs@example.org\",\n     email_verified_at: \"2019-10-03 21:38:33\",\n     updated_at: \"2019-10-03 21:38:33\",\n     created_at: \"2019-10-03 21:38:33\",\n     id: 1,\n   }\n\u003e\u003e\u003e $formio = app(Spinen\\Formio\\Client::class)\n=\u003e Spinen\\Formio\\Client {#3697\n     +token: Spinen\\Formio\\Token {#3530\n       // ...\n     },\n   }\n\u003e\u003e\u003e $formio-\u003esso($user)\n=\u003e Spinen\\Formio\\Client {#3697\n     +token: Spinen\\Formio\\Token {#3530\n       +expires_at: Carbon\\Carbon @1570153122 {#3695\n         date: 2019-10-04 01:38:42.0 +00:00,\n       },\n       +issued_at: Carbon\\Carbon @1570138722 {#3619\n         date: 2019-10-03 21:38:42.0 +00:00,\n       },\n       +jwt: \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHRlcm5hbCI6dHJ1ZSwiZm9ybSI6eyJfaWQiOiI1ZDkxNmIyNjBlYTBjNzAwMWE4ZWVlM2MifSwidXNlciI6eyJfaWQiOiJleHRlcm5hbCIsImRhdGEiOnsiZW1haWwiOiJvamFjb2JzQGV4YW1wbGUub3JnIiwiZmlyc3ROYW1lIjoiQXJ2aWQiLCJsYXN0TmFtZSI6IlJ1ZWNrZXIifSwicm9sZXMiOlsiNWQ5MTZiMjYwZWEwYzcwMDFhOGVlZTNhIl19LCJpYXQiOjE1NzAxMzg3MjIsImV4cCI6MTU3MDE1MzEyMn0.ZxWTJIteHXomGz1F7yYjSJcXvWLZQZYRrPN4cKB3KAk\",\n       +jwt_obj: {#3575\n         +\"external\": true,\n         +\"form\": {#3535\n           +\"_id\": \"5d916b260ea0c7001a8eee3c\",\n         },\n         +\"user\": {#3676\n           +\"_id\": \"external\",\n           +\"data\": {#3527\n             +\"email\": \"ojacobs@example.org\",\n             +\"firstName\": \"Arvid\",\n             +\"lastName\": \"Ruecker\",\n           },\n           +\"roles\": [\n             \"5d916b260ea0c7001a8eee3a\",\n           ],\n         },\n         +\"iat\": 1570138722,\n         +\"exp\": 1570153122,\n       },\n       +user: [\n         \"email\" =\u003e \"ojacobs@example.org\",\n         \"firstName\" =\u003e \"Arvid\",\n         \"lastName\" =\u003e \"Ruecker\",\n       ],\n     },\n   }\n\u003e\u003e\u003e collect($formio-\u003erequest('/form'))-\u003epluck('name')\n=\u003e Illuminate\\Support\\Collection {#3536\n     all: [\n       \"user\",\n       \"admin\",\n       \"userLogin\",\n       \"adminLogin\",\n       \"userRegister\",\n     ],\n   }\n\u003e\u003e\u003e\n```\n\n## Generic PHP\n\n### Examples\n\nHere is an example of getting the current user as admin:\n\n```php\n$ psysh\nPsy Shell v0.9.9 (PHP 7.2.22 — cli) by Justin Hileman\n\u003e\u003e\u003e $config = [\n     \"admin\" =\u003e [\n       \"password\" =\u003e \"password\",\n       \"login\" =\u003e [\n         \"path\" =\u003e \"/admin/login\",\n       ],\n       \"username\" =\u003e \"admin@domain.com\",\n     ],\n     \"jwt\" =\u003e [\n       \"algorithm\" =\u003e \"HS256\",\n       \"secret\" =\u003e \"--- change me now ---\",\n     ],\n     \"project\" =\u003e [\n       \"id\" =\u003e null,\n     ],\n     \"url\" =\u003e \"http://localhost:3001\",\n     \"user\" =\u003e [\n       \"form\" =\u003e null,\n       \"login\" =\u003e [\n         \"path\" =\u003e \"/user/login\",\n       ],\n       \"register\" =\u003e [\n         \"default_password\" =\u003e null,\n         \"path\" =\u003e \"/user/register\",\n       ],\n       \"roles\" =\u003e [],\n       \"sync\" =\u003e false,\n     ],\n   ]\n\u003e\u003e\u003e $guzzle = new GuzzleHttp\\Client();\n=\u003e GuzzleHttp\\Client {#2346}\n\u003e\u003e\u003e $formio = new Spinen\\Formio\\Client($config, $guzzle);\n=\u003e Spinen\\Formio\\Client {#2364\n     +token: Spinen\\Formio\\Token {#2362\n       // ...\n     },\n   }\n\u003e\u003e\u003e $formio-\u003elogin();\n=\u003e Spinen\\Formio\\Client {#2364\n     +token: Spinen\\Formio\\Token {#2362\n       // ...\n       +user: [\n         \"_id\" =\u003e \"5d916b270ea0c7001a8eee4a\",\n         \"owner\" =\u003e null,\n         \"roles\" =\u003e [\n           \"5d916b260ea0c7001a8eee39\",\n         ],\n         \"form\" =\u003e \"5d916b260ea0c7001a8eee3d\",\n         \"data\" =\u003e [\n           \"email\" =\u003e \"admin@domain.com\",\n         ],\n         \"access\" =\u003e [],\n         \"externalIds\" =\u003e [],\n         \"created\" =\u003e \"2019-09-30T02:40:39.478Z\",\n         \"modified\" =\u003e \"2019-09-30T02:40:39.482Z\",\n       ],\n     },\n   }\n\u003e\u003e\u003e $formio-\u003erequest('/current')\n=\u003e [\n     \"_id\" =\u003e \"5d916b270ea0c7001a8eee4a\",\n     \"owner\" =\u003e null,\n     \"roles\" =\u003e [\n       \"5d916b260ea0c7001a8eee39\",\n     ],\n     \"form\" =\u003e \"5d916b260ea0c7001a8eee3d\",\n     \"data\" =\u003e [\n       \"email\" =\u003e \"admin@domain.com\",\n     ],\n     \"access\" =\u003e [],\n     \"externalIds\" =\u003e [],\n     \"created\" =\u003e \"2019-09-30T02:40:39.478Z\",\n     \"modified\" =\u003e \"2019-09-30T02:40:39.482Z\",\n   ]\n\u003e\u003e\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspinen%2Flaravel-formio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspinen%2Flaravel-formio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspinen%2Flaravel-formio/lists"}