forked from Limenius/Liform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ba6e7df
Showing
21 changed files
with
1,415 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Nacho Martín | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
Liform | ||
====== | ||
|
||
Library to serialize Symfony Forms into [JSON schema](http://json-schema.org/). For use with [liform-react](https://github.com/Limenius/liform-react) or [json-editor](https://github.com/jdorn/json-editor), or any other form generator based in json-schema. | ||
|
||
It is used by [LiformBundle](https://github.com/Limenius/LiformBundle) but can be used stand-alone. | ||
|
||
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. | ||
|
||
LiformBundle 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. | ||
|
||
## Installation | ||
|
||
Open a command 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. | ||
|
||
## Usage | ||
|
||
Serializing a form into JSON Schema: | ||
|
||
```php | ||
$form = $this->createForm(CarType::class, $car, ['csrf_protection' => false]); | ||
$schema = json_encode($liform->transform($form)); | ||
``` | ||
|
||
And `$schema` will contain a JSON Schema representation such as: | ||
|
||
```js | ||
{ | ||
"title":null, | ||
"properties":{ | ||
"name":{ | ||
"type":"string", | ||
"title":"Name", | ||
"propertyOrder":1 | ||
}, | ||
"color":{ | ||
"type":"string", | ||
"title":"Color", | ||
"attr":{ | ||
"placeholder":"444444" | ||
}, | ||
"default":"444444", | ||
"description":"3 hexadecimal digits", | ||
"propertyOrder":2 | ||
}, | ||
"drivers":{ | ||
"type":"array", | ||
"title":"hola", | ||
"items":{ | ||
"title":"Drivers", | ||
"properties":{ | ||
"firstName":{ | ||
"type":"string", | ||
"propertyOrder":1 | ||
}, | ||
"familyName":{ | ||
"type":"string", | ||
"propertyOrder":2 | ||
} | ||
}, | ||
"required":[ | ||
"firstName", | ||
"familyName" | ||
], | ||
"type":"object" | ||
}, | ||
"propertyOrder":3 | ||
} | ||
}, | ||
"required":[ | ||
"name", | ||
"drivers" | ||
] | ||
} | ||
|
||
``` | ||
|
||
## 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](https://github.com/matthiasnoback/symfony-console-form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "limenius/liform", | ||
"description": "Library to transform Symfony Forms into Json Schema", | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Nacho Martín", | ||
"email": "nacho@limenius.com" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { "Limenius\\Liform\\": "src" } | ||
}, | ||
"require": { | ||
"symfony/form": "~2.3|~3.0" | ||
} | ||
} |
Oops, something went wrong.