Download the PHP package answear/liform without Composer

On this page you can find all versions of the php package answear/liform. 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 liform

Liform

Liform is a library for serializing Symfony Forms into JSON schema. It can be used along with liform-react or json-editor, or any other form generator based on json-schema.

It is used by LiformBundle but can also be used as a stand-alone library.

It is very annoying to maintain backend forms that match forms in a client technology, such as JavaScript. It is also annoying to maintain a documentation of such forms. And error prone.

Liform generates a JSON schema representation, that serves as documentation and can be used to document, validate your data and, if you want, to generate forms using a generator.

Build Status Latest Stable Version Latest Unstable Version License

Installation

Open a console, enter your project directory and execute the following command to download the latest stable version of this library:

$ composer require limenius/liform

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Liform follows the PSR-4 convention names for its classes, which means you can easily integrate Liform classes loading in your own autoloader.

Note

symfony/form ^5.0 broke backwards compatibility on some abstract functions we use. If you need to function with earlier versions, you need to use Liform v0.15 or earlier:

$ composer require limenius/liform "^0.15"

Usage

Serializing a form into JSON Schema:

And $schema will contain a JSON Schema representation such as:

Using your own transformers

Liform works by inspecting the form recursively, finding (resolving) the right transformer for every child and using that transformer to build the corresponding slice of the json-schema. So, if you want to modify the way a particular form type is transformed, you should set a transformer that matches a type with that block_prefix.

To do so, you can use the setTransformer method of the Resolver class. In this case we are reusing the StringTransformer, by overriding the widget property and setting it to my_widget, but you could use your very own transformer if you like:

Serializing initial values

This library provides a normalizer to serialize a FormView (you can create one with $form->createView()) into an array of initial values.

To obtain an array of initial values that match your json-schema.

Serializing errors

This library provides a normalizer to serialize forms with errors into an array. This part was shamelessly taken from FOSRestBundle. To use this feature copy the following code in your controller action:

To obtain an array with the errors of your form. liform-react, if you are using it, can understand this format.

Information extracted to JSON-schema

The goal of Liform is to extract as much data as possible from the form in order to have a complete representation with validation and UI hints in the schema. The options currently supported are.

Some of the data can be extracted from the usual form attributes, however, some attributes will be provided using a special liform array that is passed to the form options. To do so in a comfortable way a form extension is provided. See AddLiformExtension.php

Required

If the field is required (which is the default in Symfony), it will be reflected in the schema.

Widget

Sometimes you might want to render a field differently then the default behaviour for that type. By using the liform attributes you can specify a particular widget that determines how this field is rendered.

If the attribute widget of liform is provided, as in the following code:

The schema generated will have that widget option:

Label/Title

If you provide a label, it will be used as title in the schema.

Pattern

If the attribute pattern of attr is provided, as in the following code:

It will be extracted as the pattern option, so it can be used for validation. Note that, in addition, everything provided to attr will be preserved as well.

Description

If the attribute description of liform is provided, as in the following code, it will be extracted in the schema:

License

This library is under the MIT license. See the complete license in the file:

LICENSE.md

Acknoledgements

The technique for transforming forms using resolvers and reducers is inspired on Symfony Console Form


All versions of liform with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
symfony/form Version ^6.0|^7.0
symfony/translation Version ^6.0|^7.0
symfony/serializer Version ^6.0|^7.0
symfony/validator Version ^6.0|^7.0
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 answear/liform contains the following files

Loading the files please wait ....