Download the PHP package myparcelcom/json-schema-form-builder without Composer

On this page you can find all versions of the php package myparcelcom/json-schema-form-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package json-schema-form-builder

Json Schema Form Builder

This library provides an object-oriented API for constructing forms, which can be converted into a JSON Schema.

This package includes the following functionalities:

  1. Constructing forms and rendering them as JSON Schema.
  2. Creating simple fields such as text, number and checkbox.
  3. Creating choice fields such as select, radio and multi-select.
  4. Grouping form fields (group element).
  5. Adding translations to form elements using the LabelTranslationCollection class. This includes:
    • Field label translations (for all fields and groups).
    • Option labels (for fields with a finite set of options such as Select and Radio).
  6. Defining values for form fields.

PHP 8

The minimum PHP version is 8.4. To update dependencies on a system without PHP 8 use:

Run tests

You can run the test through docker:

Usage

The following section provides examples of how to use the library to create forms and convert them into JSON Schema.

Meta Fields

While JSON Schema is effective for laying out form structures, it has limitations in the information it allows to specify. To address this, properties that fall outside the scope of the JSON Schema specification will be stored as meta-fields. Setting these fields is handled using the Meta.php which currently supports the following:

Example: Constructing a Form and Converting it to a JSON Schema

The resulting JSON Schema will look as follows:

Example: Setting values

In some cases, you may require setting a value on a form element during its construction. This includes:

  1. Populating the field with values previously set by the user
  2. Default values

To support this, form elements allow setting a value property. These values can be obtained in a form by calling the getValues() method on the Form.php class. This method returns an associative array with the field names as keys and their respective values. This means that when serialized to JSON, it will be rendered as a JSON object (see example below).

When serialized to JSON, the resulting array will look as follows:

Example: Grouping elements

The resulting JSON Schema property for the group will look as follows:

NOTE: When defining groups, required properties that are its direct children will be added to its required property rather than the required property of the parent form.

Values in Groups

If children of a group have a value set, their values will be rendered as a nested structure. For example:

When serialized, getValues() will result in the following JSON object:

Example: Adding translations to a form element's label

The resulting JSON Schema property will look as follows:

Example: Adding translations to a Form element's labels and option labels

The resulting JSON Schema property will look as follows:

Example: Multi-Select

The resulting JSON Schema property will be of type array and look as follows:


All versions of json-schema-form-builder with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
laravel/framework Version >=12.0
ramsey/uuid Version ^4.7
opis/json-schema Version ^2.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package myparcelcom/json-schema-form-builder contains the following files

Loading the files please wait ...