PHPackages                             apollo29/forms-engine - 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. apollo29/forms-engine

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

apollo29/forms-engine
=====================

FormsEngine

0.1.2(6y ago)047[20 issues](https://github.com/tdascoli/forms-engine/issues)[9 PRs](https://github.com/tdascoli/forms-engine/pulls)MITPHP

Since Jun 23Pushed 3y agoCompare

[ Source](https://github.com/tdascoli/forms-engine)[ Packagist](https://packagist.org/packages/apollo29/forms-engine)[ RSS](/packages/apollo29-forms-engine/feed)WikiDiscussions develop Synced 4d ago

READMEChangelog (10)Dependencies (12)Versions (21)Used By (0)

FormsEngine
===========

[](#formsengine)

Library to build forms on basis of Bootstrap 4 templates. This library includes customizable templates to use also other frameworks than Bootstrap, has multilanguage support and configurable ways to persist the form data.

[![Latest Version](https://camo.githubusercontent.com/074b6386f0fb4001f365af1cbcc84126f1d64001f88c7b6ad65d5a2ea5d69d7d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61706f6c6c6f32392f666f726d732d656e67696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/apollo29/forms-engine)[![Build Status](https://camo.githubusercontent.com/007675b87bc290448a365a9464a840aa56c43da15301a5d9c71ee13b67bb8e96/68747470733a2f2f7472617669732d63692e636f6d2f74646173636f6c692f666f726d732d656e67696e652e7376673f6272616e63683d646576656c6f70)](https://travis-ci.com/tdascoli/forms-engine)

- [Install](#install)
- [Usage](#usage)
- [Dependencies](#dependencies)
- [Configuration](#configuration)
    - [set Prefix directory](#set-prefix-directory)
    - [get Configuration variable](#get-configuration-variable)
- [Translations](#translations)
- [Templates](#templates)
- [Option `FormsEngine\Questions\Element\Option`](#option-formsenginequestionselementoption)
- [Elements `FormsEngine\Questions\Element`](#elements-formsenginequestionselement)
    - [Text, E-Mail, Number, Date, DateTime](#text-e-mail-number-date-datetime)
    - [Textarea](#textarea)
    - [Hidden](#hidden)
    - [Typeahead](#typeahead)
    - [Radio](#radio)
    - [RadioGroup](#radiogroup)
    - [Checkbox](#checkbox)
    - [CheckboxGroup](#checkboxgroup)
    - [Select](#select)
    - [YesNo](#yesno)
    - [Paragraph](#paragraph)
    - [Title](#title)
    - [Button, Reset, Submit](#button-reset-submit)
- [De-/Serialization of form definitions `FormsEngine\Questions\Loader`](#de-serialization-of-form-definitions-formsenginequestionsloader)
- [Pagination `FormsEngine\Questions\Pagination`](#pagination-formsenginequestionspagination)
- [API and Persistence `FormsEngine\Answers\Persistence`](#api-and-persistence-formsengineanswerspersistence)
    - [CSV](#csv)
    - [E-Mail](#e-mail)
    - [JSON](#json)
    - [JSONDB](#jsondb)
    - [MySQL](#mysql)
    - [XLSX](#xlsx)
    - [Implement own Persistence](#implement-own-persistence)

Install
-------

[](#install)

Install using [composer](https://getcomposer.org/).

```
$ composer require apollo29/forms-engine
```

Usage
-----

[](#usage)

In your `index.php` you have to create a new `FormsEngine` instance first.

```
use FormsEngine\FormsEngine;

$engine = new FormsEngine();
```

Then add some Elements to create your form, and render it.

```
use FormsEngine\Questions\Element;

$r = $engine->renderer();

$r->add(new Element\Title('My First FormsEngine'));
$r->add(new Element\Text('Text Input Label','Text Input Placeholder','Text Input Helptext'));

$r->render();
```

Dependencies
------------

[](#dependencies)

A List of all Dependencies used by this Library.

**CSS/JS**

- [bootstrap](https://getbootstrap.com/docs/4.3/components/forms/)
- [material](https://daemonite.github.io/material/)
- [jquery-typeahead](https://github.com/running-coder/jquery-typeahead)
- [Parsley.JS](http://parsleyjs.org/) Input validation
- [JOII (JavaScript Object Inheritance Implementation](https://github.com/haroldiedema/joii) used for JS Objects of `FormsEngine\Questions\Element`

**PHP**

- [twig/twig](https://twig.symfony.com/) templating
- [myclabs/php-enum](https://github.com/myclabs/php-enum)
- [phpcollection/phpcollection](http://jmsyst.com/libs/php-collection) Sets, Sequences, Collections
- [philipp15b/php-i18n](https://github.com/Philipp15b/php-i18n) i18n
- [slim/slim](http://www.slimframework.com/) RESTful
- [nategood/httpful](http://phphttpclient.com/) HTTP calls
- [league/csv](https://csv.thephpleague.com/) CSV
- [rakibtg/sleekdb](https://sleekdb.github.io/) JSONDB
- [phpmailer/phpmailer](https://github.com/PHPMailer/PHPMailer) E-Mail
- [phpoffice/phpspreadsheet](https://github.com/PHPOffice/PhpSpreadsheet) Excel

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

[](#configuration)

Set a session var with name `configFile` and the path and json-filename of your own `config.json`. See below the standard`config.json` as an example. If your happy with the standard `config.json`, you don't need to set the session var.

```
$_SESSION['configFile'] = __DIR__ . '/config.json';
```

**config.json**

```
{
    "addDirPrefix":true,
    "templateDir":"/Templates/",
    "langDir":"/Translations/",
    "form" : {
        "dir":"/forms/",
        "name":"defaultForm",
        "method":"ajax",
        "messageAfterSubmit":true,
        "createAnother":true,
        "addTimestamp":false
    },
    "pagination": {
      "active":true,
      "reset":false
    },
    "render" : {
        "load":"COOKIE",
        "config":"jsonForm"
    },
    "persistence" : {
        "type":"JSONDB",
        "email": {
            "emailTo":"test@test.test"
        },
        "externalConfigs":[]
    }
}
```

### set Prefix directory

[](#set-prefix-directory)

*todo*

```
Config::setDirPrefix(__DIR__, "dir");
Config::setDirPrefix(__DIR__, "langDir");
Config::setDirPrefix(__DIR__, "templateDir");
```

### get Configuration variable

[](#get-configuration-variable)

*todo*

```
Config::getInstance()->get('form','name')
```

Translations
------------

[](#translations)

*todo*

Templates
---------

[](#templates)

*todo*

Option `FormsEngine\Questions\Element\Option`
---------------------------------------------

[](#option-formsenginequestionselementoption)

Used for `RadioGroup`, `CheckboxGroup`, `Typeahead` and `Select` Elements.

Usage

```
$option = new Option();

$option->add('first',1);
$option->add('second',2);
$option->add('third',3);
```

**Public Methods**

- `__construct()` constructor
- `add($label, $value, $selected = false)` add values to `Option` Element
- `addAll($options)` add an Array of `Option` Elements
- `all()` get All Elements
- `static create($label, $value, $selected = false)` returns an `Option` Element
- `serialize()` get serialized Element for persistence, array with all attributes and values.
- `static deserialize($object)` deserialize Object to Element

**Private Methods**

- `static camelCase($str, array $noStrip = [])` get String camelCased, used for `id`

Elements `FormsEngine\Questions\Element`
----------------------------------------

[](#elements-formsenginequestionselement)

All Elements are - mostly - standard [HTML5 input fields](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input) and have the following methods:

**Public Methods**

- `___construct($label)` when not otherwise stated, this is the default constructor
- `serialize()` get serialized Element for persistence, array with all attributes and values.
- `prepare()` see `serialize()`
- `static deserialize($object)` deserialize Object to Element
- `toObjectVar($key, $value, $class = null)` used to map an array to key/value of Element.
- `script()` get all JavaScript code to render.
- `required()` set Element as required
- `readonly()` set Element as readonly
- `disabled()` set Element as disabled
- `inputmask($mask,$type = 'mask')` set Inputmask (see Dependencies for further Documentation)
- `addStyle($style)`add additional CSS class
- `attr($attr, $value)` add attributes

**Private Methods**

- `setId($id,$isName = false)` set id and optional also name attribute
- `setName($name)` set name attribute
- `static camelCase($str, array $noStrip = [])` get String camelCased, used for `setId` and `setName`

### Text, E-Mail, Number, Date, DateTime

[](#text-e-mail-number-date-datetime)

Extends from `Input`

Usage

```
$text   = new Text('Label','Placeholder','Helptext');

$email  = new Email('Label','Placeholder','Helptext');

$number = new Number('Label','Placeholder','Helptext');

$date     = new Date('Label','Placeholder','Helptext');
$dateTime = new DateTime('Label','Placeholder','Helptext');
```

Template/HTML (`type` is different according to Element)

```

  Label

  Helptext

```

Public Methods

- `__construct($label, $placeholder = null, $helptext = null)` constructor
- `render($twig)` render Method for Twig Template Engine

### Textarea

[](#textarea)

Extends from `Input`

Usage

```
$element = new Textarea('Label','Helptext');
```

Template/HTML

```

  Label

  Helptext

```

Public Methods

- `__construct($label, $helptext = null)` constructor
- `render($twig)` render Method for Twig Template Engine

### Hidden

[](#hidden)

Extends from `Element`

Usage

```
$element = new Hidden('id','Value');
```

Template/HTML

```

```

Public Methods

- `__construct($id, $value = null)` constructor
- `render($twig)` render Method for Twig Template Engine

### Typeahead

[](#typeahead)

Extends from `Text`

Usage, with Array

```
$options = array('first','second','third','fourth');

$array = new Typeahead('Label',$options,'Placeholder','Helptext');
```

Usage, with `Option`. See `Option` for more information

```
$option = new Option();
$option->add('Germany','GER');
$option->add('Italy','ITA');
$option->add('Switzerland','SUI');

$option = new Typeahead('Label',$option,'Placeholder','Helptext');
```

Template/HTML

```

  Label

  Helptext

```

Public Methods

- `__construct($label, $options, $placeholder = null, $helptext = null)` constructor
- `render($twig)` render Method for Twig Template Engine

### Radio

[](#radio)

Extends from `Element`

Usage

```
$element = new Radio('Label','Value','Name',true);
```

Template/HTML

```

    Label

```

Public Methods

- `__construct($label, $value, $name, $checked = false)` constructor
- `render($twig)` render Method for Twig Template Engine

### RadioGroup

[](#radiogroup)

Extends from `Element`

Usage, see `Option` for more information

```
$option = new Option();
$option->add('first',1);
$option->add('second',2);
$option->add('third',3);

$element = new RadioGroup('Label',$option,'Name');
```

Template/HTML

```

  Label

        first

```

Public Methods

- `__construct($label, $options, $name = null)` constructor
- `render($twig)` render Method for Twig Template Engine

### Checkbox

[](#checkbox)

Extends from `Element`

Usage

```
$element = new Checkbox('Label','Value',true);
```

Template/HTML

```

    Label

```

Public Methods

- `__construct($label, $value, $checked = false)` constructor
- `render($twig)` render Method for Twig Template Engine

### CheckboxGroup

[](#checkboxgroup)

Extends from `Element`

Usage, see `Option` for more information

```
$option = new Option();
$option->add('first',1);
$option->add('second',2);
$option->add('third',3);

$element = new CheckboxGroup('Label',$option);
```

Template/HTML

```

  Label

        first

```

Public Methods

- `__construct($label, $options)` constructor
- `render($twig)` render Method for Twig Template Engine
- `elementKeys()` all `Option` Keys

### Select

[](#select)

Extends from `Element`

Usage, see `Option` for more information

```
$option = new Option();
$option->add('first',1);
$option->add('second',2);
$option->add('third',3);

$element = new Select('Label',$option,true,'Helptext');
```

Template/HTML

```

  Label

    first

  Helptext

```

Public Methods

- `__construct($label,$options,$nullable = false,$helptext = null)` constructor
- `render($twig)` render Method for Twig Template Engine

### YesNo

[](#yesno)

Renders a Yes/No `Radio` Element, with "Yes" / "No" or boolean values.

Extends from `ElementGroup`

Usage

```
$element = new YesNo('Name',true);
```

Template/HTML, see `Radio` Element

Public Methods

- `__construct($name, $booleans = false)` constructor
- `render($twig)` render Method for Twig Template Engine

### Paragraph

[](#paragraph)

Extends from `Element`

Usage

```
$element = new Paragraph('Title','Description');
```

Template/HTML

```
Title
Description
```

Public Methods

- `__construct($title=null,$description=null)` constructor
- `render($twig)` render Method for Twig Template Engine

### Title

[](#title)

There is only one `Title` Element allowed per Form.

Extends from `Paragraph`

Usage

```
$element = new Title('Form Title','Description');
```

Template/HTML

```
Form Title
Description
```

Public Methods

- `__construct($title,$description=null)` constructor
- `render($twig)` render Method for Twig Template Engine

### Button, Reset, Submit

[](#button-reset-submit)

See #26.

Extends from `Element`

Usage

```
$button       = new Button('Button');

$reset        = new Reset('Reset'); // Shorthand
$resetButton  = new Button('Reset Button');

$submit       = new Submit('Submit'); // Shorthand
$submitButton = new Button('Submit Button');
```

Template/HTML

```

  Button

  Reset

  Submit

```

Public Methods

- `__construct($label,$buttonType=null)` constructor
- `render($twig)` render Method for Twig Template Engine

De-/Serialization of form definitions `FormsEngine\Questions\Loader`
--------------------------------------------------------------------

[](#de-serialization-of-form-definitions-formsenginequestionsloader)

*todo*

Pagination `FormsEngine\Questions\Pagination`
---------------------------------------------

[](#pagination-formsenginequestionspagination)

*todo*

API and Persistence `FormsEngine\Answers\Persistence`
-----------------------------------------------------

[](#api-and-persistence-formsengineanswerspersistence)

*todo*

### CSV

[](#csv)

### E-Mail

[](#e-mail)

### JSON

[](#json)

### JSONDB

[](#jsondb)

### MySQL

[](#mysql)

### XLSX

[](#xlsx)

### Implement own Persistence

[](#implement-own-persistence)

```
namespace Somewhere\Persistence;

use \FormsEngine\Answers\Persistence\Persistence;

class TestPersistence implements Persistence {

  public static function persist($name, $data){
    echo 'Insert Data into '.$name.': '.\implode(',',$data);
  }

  public static function load($name){
      echo 'Load Data from '.$name;
  }
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

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 ~4 days

Total

11

Last Release

2473d ago

Major Versions

0.0.7 → v2.x-dev2019-07-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/1500518ee2e1f14cbdf3ca7f09f74a0aa24d1c035615ac99639c1879a3f507aa?d=identicon)[tdascoli](/maintainers/tdascoli)

---

Top Contributors

[![tdascoli](https://avatars.githubusercontent.com/u/4374387?v=4)](https://github.com/tdascoli "tdascoli (385 commits)")

### Embed Badge

![Health badge](/badges/apollo29-forms-engine/health.svg)

```
[![Health](https://phpackages.com/badges/apollo29-forms-engine/health.svg)](https://phpackages.com/packages/apollo29-forms-engine)
```

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[lullabot/drainpipe

An automated build tool to allow projects to have a set standardized operations scripts.

41716.4k2](/packages/lullabot-drainpipe)[abydahana/aksara

Aksara is a CodeIgniter based CRUD Toolkit you can use to build complex applications become shorter, secure and more reliable just in a few lines of code. Serving both CMS or Framework, produce both HEADLESS (RESTful API) or TRADITIONAL (Browser Based), just by writing single controller. Yet it's reusable, scalable and ready to use!

1101.2k](/packages/abydahana-aksara)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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