Download the PHP package w3r-one/json-schema-bundle without Composer

On this page you can find all versions of the php package w3r-one/json-schema-bundle. 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-bundle

JsonSchemaBundle

A bundle to serialize a Symfony Form into a JSON Schema (RFC 2020-12).

Installation

$ composer require w3r-one/json-schema-bundle

If you're not using Symfony Flex, you've to register the bundle manually:

Usage

View the generated JSON Schema

Purpose

The goal behind this bundle is based on the fact that it is complicated for a modern front-end application to maintain a form component that is not mapped directly on a Symfony FormType.

Most of the time, the front-end component is defining form's props in a static way and if the back-end wants to update the form, we need to work twice, it's error prone and it's not extensible at all.

The main idea is to give the lead to the back-end, provide a JSON schema dynamically that will detail the full component and its related documentation ; the front-end "just" have to display and handle the form on his side.

If the Form is changing or even if it's dynamic based on some roles / scopes / etc., the front-end developer have nothing to change.

It's also allow working with forms directly in Twig and in the same time in a Javascript context.

The business rules are not duplicated and are only handled by the back-end.

This bundle doesn't provide any Front-End component, feel free to choose the stack that feet your needs to build your own Javascript Form.

Logic

Concrete exemple

This example allow to handle a form directly in Twig without XHR AND with async Javascript, feel free to drop completely the twig/not async part.

$this->em is a simple reference to the EntityManagerInterface.

$this->apiSerializer is a simple service based on the Symfony Serializer.

View the service

Architecture

The resolver will traverse the form, guess the right Transformer for each property and apply recursive transformations based on the following schema.

Legend

You can add your own transformers, or override/extend the transformers of your choice by yourself, see the dedicated section of this readme.

If needed, the form extension allow you to add custom props in w3r_one_json_schema to pass to your json specs.

Translator

This bundle relies on Symfony TranslatorInterface to translate:

The translation domain is dynamically retrieved from translation_domain option:

CSRF

If you've installed symfony/security-csrf and enabled crsf_protection on you FormType, the bundle will automatically add the correct csrf property (_token by default) with the default generated value (thanks to the TokenGeneratorInterface) in a hidden widget.

Built-in FormType

All Symfony FormTypes as 6.2 version are supported.

View the complete list * [TextType](https://symfony.com/doc/current/reference/forms/types/text.html) * [TextareaType](https://symfony.com/doc/current/reference/forms/types/textarea.html) * [EmailType](https://symfony.com/doc/current/reference/forms/types/eamil.html) * [PasswordType](https://symfony.com/doc/current/reference/forms/types/password.html) * [SearchType](https://symfony.com/doc/current/reference/forms/types/search.html) * [UrlType](https://symfony.com/doc/current/reference/forms/types/url.html) * [TelType](https://symfony.com/doc/current/reference/forms/types/tel.html) * [ColorType](https://symfony.com/doc/current/reference/forms/types/color.html) * [FileType](https://symfony.com/doc/current/reference/forms/types/file.html) * [RadioType](https://symfony.com/doc/current/reference/forms/types/radio.html) * [UuidType](https://symfony.com/doc/current/reference/forms/types/uuid.html) * [UlidType](https://symfony.com/doc/current/reference/forms/types/ulid.html) * [HiddenType](https://symfony.com/doc/current/reference/forms/types/hidden.html) * [IntegerType](https://symfony.com/doc/current/reference/forms/types/integer.html) * [MoneyType](https://symfony.com/doc/current/reference/forms/types/money.html) * [NumberType](https://symfony.com/doc/current/reference/forms/types/number.html) * [PercentType](https://symfony.com/doc/current/reference/forms/types/percent.html) * [RangeType](https://symfony.com/doc/current/reference/forms/types/range.html) * [ChoiceType](https://symfony.com/doc/current/reference/forms/types/choice.html) * [EnumType](https://symfony.com/doc/current/reference/forms/types/enum.html) * [EntityType](https://symfony.com/doc/current/reference/forms/types/entity.html) * [CountryType](https://symfony.com/doc/current/reference/forms/types/country.html) * [LanguageType](https://symfony.com/doc/current/reference/forms/types/language.html) * [LocaleType](https://symfony.com/doc/current/reference/forms/types/locale.html) * [TimezoneType](https://symfony.com/doc/current/reference/forms/types/timezone.html) * [CurrencyType](https://symfony.com/doc/current/reference/forms/types/currency.html) * [DateType](https://symfony.com/doc/current/reference/forms/types/date.html) * [DateTimeType](https://symfony.com/doc/current/reference/forms/types/datetime.html) * [TimeType](https://symfony.com/doc/current/reference/forms/types/time.html) * [WeekType](https://symfony.com/doc/current/reference/forms/types/week.html) * [BirthdayType](https://symfony.com/doc/current/reference/forms/types/birthday.html) * [DateIntervalType](https://symfony.com/doc/current/reference/forms/types/dateinterval.html) * [CollectionType](https://symfony.com/doc/current/reference/forms/types/collection.html) * [CheckboxType](https://symfony.com/doc/current/reference/forms/types/checkbox.html) * [ButtonType](https://symfony.com/doc/current/reference/forms/types/button.html) * [ResetType](https://symfony.com/doc/current/reference/forms/types/reset.html) * [SubmitType](https://symfony.com/doc/current/reference/forms/types/submit.html) * [RepeatedType](https://symfony.com/doc/current/reference/forms/types/repeated.html)

Supported JSON Schema specs

Unsupported JSON Schema specs (for now)

Additional JSON Schema specs

All non standards properties are wrapped into options property.

It includes:

If you want to pass other specific properties to your component, feel free to wrap them into w3r_one_json_schema property.

For example:

Override / Extend

You can totally override or extend any transformer / json specs of this bundle.

Widget / Layout resolving

In your FormTypes, you can override any widget / layout of your choice thanks to the w3r_one_json_schema option.

For example:

You can also override the default layout globally if needed:

FormType Transformers

You can register your own transformers.

Tag them with the name w3r_one_json_schema.transformer and define the form_type you want to transform.

Your transformers are resolved before ours, so if you override an existing transformer, it'll be executed in place of the bundle built-in ones.

Transformers must implement the TransformerInterface.

The proper approach is to extend one of ours abstract or specific transformers, redefine method transform, call the parent function and extending/overwriting the json schema before returning it.

You can also implement directly the interface, but you've to manage everything by yourself in this case.

Example 1

You're using VichUploaderBundle and you want to serialize specific options of this bundle.

Just extend the ObjectTransformer, call the parent function, embed your json props and voila!

Example 2

You want to add a PositionType as an integer.

Here we just extend the correct base IntegerTransformer.

Example 3

You want to override the TextareaType to replace it by a rich-text / wysiwyg editor.

Note that a better approach would have been to use a WysiwygType and to create a specific WysiwygTypeTransformer.


All versions of json-schema-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
doctrine/inflector Version >=1.4
symfony/config Version >=4.4
symfony/dependency-injection Version >=4.4
symfony/finder Version >=4.4
symfony/form Version >=4.4
symfony/http-foundation Version >=4.4
symfony/http-kernel Version >=4.4
symfony/intl Version >=4.4
symfony/security-csrf Version >=4.4
symfony/translation Version >=4.4
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 w3r-one/json-schema-bundle contains the following files

Loading the files please wait ....