PHPackages                             code16/formoj - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. code16/formoj

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

code16/formoj
=============

Customizable form renderer

v7.2.0(4mo ago)332.6k↑130.8%5[5 issues](https://github.com/code16/formoj/issues)[1 PRs](https://github.com/code16/formoj/pulls)PHPPHP ^8.2|^8.3|^8.4|^8.5CI passing

Since Mar 1Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/code16/formoj)[ Packagist](https://packagist.org/packages/code16/formoj)[ RSS](/packages/code16-formoj/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (71)Used By (0)

[![Formoj for Laravel](docs/img/logo-v2.png)](docs/img/logo-v2.png)

Formoj for Laravel is a form generator package.

[![](/docs/img/formoj.png)](/docs/img/formoj.png)
*Example of a Formoj form (with de default style).*

You can picture it like a small Google Form but with full control on it. Formoj takes care of the form storage and display, allows an administrator to manage forms (notifications, export answers in XLS format) and, of course, stores answers.

The project is separated in 3 modules:

- the Vue-based front package, which is a distinct NPM package (see installation instructions below)
- the backend code: models and migrations, controllers, jobs, notifications, ...
- and finally an optional [Sharp-based](https://sharp.code16.fr) administration tool, to manage forms, sections, fields and export answers.

Installation
------------

[](#installation)

### Vue plugin

[](#vue-plugin)

```
npm install formoj
```

#### Basic

[](#basic)

```
import Vue from 'vue';
import Formoj from 'formoj';

Vue.use(Formoj);
```

#### Advanced Configuration

[](#advanced-configuration)

```
Vue.use(Formoj, {
    apiBaseUrl: '/custom/api',
    scrollOffset: 160,
    locale: 'en',
    i18n: {
      en: {
        'section.button.next': 'Next section',
      }
    }
});
```

configdescriptionapiBaseUrlBase URL of the formoj API (define it as `base_url` in laravel in `config/formoj.php`)scrollOffsetAdd offset to the automatic scroll top behavior, useful when there is a fixed header in the site.localeLocale used in all forms messages, buttons, etc... If not set, the `` attribute is used.i18nLocalized messages to customize default formoj i18n messages, see [`lang`](https://github.com/code16/formoj/tree/master/packages/formoj/src/lang) files### Laravel module

[](#laravel-module)

Formoj requires Laravel 7+, Carbon 2.0+, and maatwebsite/excel 3.1+.

Install the package via composer:

```
composer require code16/formoj
```

Then run this to create the needed tables in the database:

```
php artisan migrate
```

You may publish the config file:

```
php artisan vendor:publish --provider="Code16\Formoj\FormojServiceProvider" --tag="config"
```

And the lang file, if you need to update or add a translation (consider a PR in this case):

```
php artisan vendor:publish --provider="Code16\Formoj\FormojServiceProvider" --tag="lang"
```

### Update Formoj

[](#update-formoj)

Warning: when updating Formoj with `composer update code16/formoj`, **be sure to also execute** `npm install formoj` to keep back and front code in line.

Create a form
-------------

[](#create-a-form)

### With Sharp

[](#with-sharp)

If your project is already using [Sharp 6 for Laravel](https://code16.sharp.fr), great. If not, and if you want to use it with Formoj, first [install the package](https://sharp.code16.fr/docs/guide/#installation).

Then we need to configure Formoj in `config/sharp.php`:

```
return [
    // config/sharp.php

    [...],

    "entities" => [
        "formoj_form" => [
            "label" => "Form",
            "list" => \Code16\Formoj\Sharp\FormojFormSharpEntityList::class,
            "show" => \Code16\Formoj\Sharp\FormojFormSharpShow::class,
            "form" => \Code16\Formoj\Sharp\FormojFormSharpForm::class,
            "validator" => \Code16\Formoj\Sharp\FormojFormSharpValidator::class,
        ],
        "formoj_section" => [
            "label" => "Section",
            "list" => \Code16\Formoj\Sharp\FormojSectionSharpEntityList::class,
            "form" => \Code16\Formoj\Sharp\FormojSectionSharpForm::class,
            "show" => \Code16\Formoj\Sharp\FormojSectionSharpShow::class,
            "validator" => \Code16\Formoj\Sharp\FormojSectionSharpValidator::class,
        ],
        "formoj_field" => [
            "label" => "Field",
            "list" => \Code16\Formoj\Sharp\FormojFieldSharpEntityList::class,
            "form" => \Code16\Formoj\Sharp\FormojFieldSharpForm::class,
            "validator" => \Code16\Formoj\Sharp\FormojFieldSharpValidator::class,
        ],
        "formoj_answer" => [
            "label" => "Answer",
            "list" => \Code16\Formoj\Sharp\FormojAnswerSharpEntityList::class,
            "show" => \Code16\Formoj\Sharp\FormojAnswerSharpShow::class,
            "policy" => \Code16\Formoj\Sharp\Policies\FormojAnswerSharpPolicy::class,
        ],
        "formoj_reply" => [
            "list" => \Code16\Formoj\Sharp\FormojReplySharpEntityList::class,
            "policy" => \Code16\Formoj\Sharp\Policies\FormojReplySharpPolicy::class,
        ],
    ],

    "menu" => [
        [
            "label" => "Formoj",
            "entities" => [
                [
                    "entity" => "formoj_form",
                    "label" => "Forms",
                    "icon" => "fa-list-alt"
                ]
            ]
        ]
    ],

    [...]
];
```

You can of course adapt this, depending on your needs: use our own subclasses, tweak the menu...

This will add a full Formoj administration in Sharp:

[![](/docs/img/sharp-01.png)](/docs/img/sharp-01.png)

[![](/docs/img/sharp-02.png)](/docs/img/sharp-02.png)

[![](/docs/img/sharp-03.png)](/docs/img/sharp-03.png)

[![](/docs/img/sharp-04.png)](/docs/img/sharp-04.png)

[![](/docs/img/sharp-05.png)](/docs/img/sharp-05.png)

### Without Sharp

[](#without-sharp)

Formoj does not provide any other admin tool for now, so in this case, well, you're free to do as you want.

There are a couple methods to help you handle section and field creation, for instance:

```
$section = $form->createSection("My section");

$text = $section->newTextField("text")
                ->setRequired()
                ->setHelpText("help")
                ->setMaxLength(50)
                ->create();

$select = $section->newSelectField("select", ["option A", "option B"])
                  ->setRequired()
                  ->setHelpText("help")
                  ->setMultiple()->setMaxOptions(2)
                  ->create();
```

Manage a form
-------------

[](#manage-a-form)

Once again, with Sharp you'll find all the appropriate tooling. This section describes

### Form availability

[](#form-availability)

A form can optionally defined a `published_at` and/or a `unpublished_at` dates: outside this period, the form is displayed with an adapted message.

### Form notifications

[](#form-notifications)

The form administrator can choose (for each form) to be notified by mail at `formoj_form.administrator_email` in two ways:

- `formoj_form.notifications_strategy` = "every": after every answer
- `formoj_form.notifications_strategy` = "grouped": a summary of answers of one given day is sent daily.

To configure the "grouped" strategy, you'll have to schedule the `Code16\Formoj\Console\SendFormojNotificationsForYesterday` Command, which will send all answers of yesterday.

### Form sections

[](#form-sections)

A Form is made of sections, which contains fields. If the form contains more than one section, it will be displayed one section at a time, with "Next" button.

### Field types

[](#field-types)

Formoj can display these types of fields:

- `text`, which is a single line text, with an optional `max_length` constraint
- `textarea`, with a and `rows_count` and an optional `max_length`
- `select`, which can either be `multiple` (checklist, with an optional `max_options` attribute) or not (single select).
- `upload`, with a `max_size` expressed in MB and an optional allowed extension list named `accept` (upload and storage directory and disk are configurable in `config/formoj.php`)
- and finally `heading`, which is not a field, but a text separator.

Embed a form
------------

[](#embed-a-form)

A given form can then be embedded anywhere with this DOM:

```

```

Work with answers
-----------------

[](#work-with-answers)

In addition to the notification system, the form administrator can export answers at any time on a xlsx format, via the `Code16\Formoj\Job\ExportAnswersToXls` job, which can be called this way:

```
ExportAnswersToXls::dispatch($form, $fileName, $answers);
```

Where:

- `$form` is a `Code16\Formoj\Models\Form` instance
- `$fileName` is the export file name (export directory and disk are configurable in `config/formoj.php`)
- and `$answers` is a Collection of `Code16\Formoj\Models\Answers`; this argument is nullable, all answers of `$form` are exported by default.

Is Sharp is configured, it will provide a dedicated Command to handle this export (as well as one to display an answer).

Styling the form
----------------

[](#styling-the-form)

Formoj uses SASS/SCSS language for styles. You can import the style with sass import:

```
@import 'formoj/scss/themes/default';
```

The default theme is very basic and is meant to be customized by your own code. Some variable are available and can be overridden, see [`formoj/scss/_variables.scss`](https://github.com/code16/formoj/blob/master/packages/formoj/scss/_variables.scss)

### Bootstrap integration

[](#bootstrap-integration)

```
@import 'formoj/scss/themes/bootstrap';

$formoj-form-appearance: 'card';
$formoj-loading-appearance: 'spinner';
```

The bootstrap theme bind all bootstrap's form classes to formoj elements. By default the form has a `card` appearance, you may want to reset that behavior.

```
$formoj-form-appearance: 'none';
```

In addition, the select and checkboxes can have the bootstrap's `custom-control` style

```
$formoj-select-appearance: 'custom';
```

Contributing
------------

[](#contributing)

Setup prototipoj

```
    cd ./prototipoj
    composer install

```

Build front-end

```
    cd ./prototipoj
    npm install

    # Watch and auto re-build formoj package files
    npm run watch

    # Build all dist files
    npm run prod
```

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance74

Regular maintenance activity

Popularity31

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity92

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 72% 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 ~54 days

Recently: every ~160 days

Total

47

Last Release

125d ago

Major Versions

v2.2.5 → v3.0.02020-12-23

3.1.0 → v4.0.0-beta.12021-05-17

v4.1.1 → v5.0.02022-03-09

v5.1.0 → v6.0.02023-10-26

v6.2.1 → v7.0.12025-02-21

PHP version history (9 changes)v1.0PHP &gt;=7.1.3

v2.2.4PHP &gt;=7.3

v3.0.0PHP &gt;=7.4

v4.1.0PHP ^7.4|^8.0|^8.1

v5.0.0PHP ^8.0|^8.1

v5.1.0PHP ^8.0|^8.1|^8.2

v6.2.0PHP ^8.0|^8.1|^8.2|^8.3

v7.0.1PHP ^8.2|^8.3|^8.4

v7.2.0PHP ^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

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

---

Top Contributors

[![dvlpp](https://avatars.githubusercontent.com/u/973325?v=4)](https://github.com/dvlpp "dvlpp (170 commits)")[![smknstd](https://avatars.githubusercontent.com/u/2412608?v=4)](https://github.com/smknstd "smknstd (37 commits)")[![PatrickePatate](https://avatars.githubusercontent.com/u/16721134?v=4)](https://github.com/PatrickePatate "PatrickePatate (13 commits)")[![PierreBillaud](https://avatars.githubusercontent.com/u/43741101?v=4)](https://github.com/PierreBillaud "PierreBillaud (9 commits)")[![aguingand](https://avatars.githubusercontent.com/u/17453506?v=4)](https://github.com/aguingand "aguingand (3 commits)")[![kravetz](https://avatars.githubusercontent.com/u/13004106?v=4)](https://github.com/kravetz "kravetz (2 commits)")[![adriaardila](https://avatars.githubusercontent.com/u/2029010?v=4)](https://github.com/adriaardila "adriaardila (2 commits)")

---

Tags

form-builderlaravel-packagesharp-for-laravel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/code16-formoj/health.svg)

```
[![Health](https://phpackages.com/badges/code16-formoj/health.svg)](https://phpackages.com/packages/code16-formoj)
```

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[whitecube/laravel-timezones

Store UTC dates in the database and work with custom timezones in the application.

106106.2k](/packages/whitecube-laravel-timezones)[ronasit/laravel-helpers

Provided helpers function and some helper class.

1475.7k13](/packages/ronasit-laravel-helpers)[team-nifty-gmbh/tall-datatables

A package to create datatables using alpinejs, tailwind, livewire and laravel

1217.2k1](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

116.6k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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