PHPackages                             mcfedr/json-form - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. mcfedr/json-form

ActiveSymfony-bundle[Parsing &amp; Serialization](/categories/parsing)

mcfedr/json-form
================

A couple of helper files for handling json with symfony forms

4.8.0(4y ago)1387.5k7[1 PRs](https://github.com/mcfedr/json-form/pulls)1MITPHPPHP &gt;=8.0

Since Sep 11Pushed 3y ago2 watchersCompare

[ Source](https://github.com/mcfedr/json-form)[ Packagist](https://packagist.org/packages/mcfedr/json-form)[ RSS](/packages/mcfedr-json-form/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (14)Versions (22)Used By (1)

Json Form helper
================

[](#json-form-helper)

Simply use the `JsonControllerTrait` and then use forms as you would normally, but they now expect to receive JSON.

[![Latest Stable Version](https://camo.githubusercontent.com/9d360064ab6101d985d311bd1d71d60163114b2f5271020a56812077d206e2e0/68747470733a2f2f706f7365722e707567782e6f72672f6d63666564722f6a736f6e2d666f726d2f762f737461626c652e706e67)](https://packagist.org/packages/mcfedr/json-form)[![License](https://camo.githubusercontent.com/6db2fb231e1096be96243d447d6b0fff3a1fd54e90380a7bccad49179c1ff494/68747470733a2f2f706f7365722e707567782e6f72672f6d63666564722f6a736f6e2d666f726d2f6c6963656e73652e706e67)](https://packagist.org/packages/mcfedr/json-form)[![Build Status](https://camo.githubusercontent.com/092819824ec95e6a018c3d84ac3593804afde38158c194f9bc9c1f835e354713/68747470733a2f2f7472617669732d63692e6f72672f6d63666564722f6a736f6e2d666f726d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mcfedr/json-form)

Install
-------

[](#install)

### Composer

[](#composer)

```
php composer.phar require mcfedr/json-form
```

### AppKernel

[](#appkernel)

Include the bundle in your AppKernel

```
public function registerBundles()
{
    $bundles = array(
        ...
        new Mcfedr\JsonFormBundle\McfedrJsonFormBundle()
```

JSON
----

[](#json)

The expected JSON will be just like that form values that would be sent.

Suppose you have the following form type

```
class AccountType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name');
    }

    public function getBlockPrefix()
    {
        return 'account';
    }
}
```

Then the JSON should be

```
{
    "account": {
        "name": "Fred"
    }
}
```

Example
-------

[](#example)

```
class AccountController extends AbstractController
    use JsonControllerTrait;

    /**
     * @Route("/accounts", methods={"POST"})
     */
    public function accountCreateAction(Request $request, $uuid) {
        $account = new Account();
        $form = $this->createJsonForm(AccountType::class, $account);
        $this->handleJsonForm($form, $request);

        $em = $this->getDoctrine()->getManager();
        $em->persist($account);
        $em->flush();

        return $this->json([
            'account' => $account
        ]);
    }
}
```

For Symfony 3.x you will need to extend `Controller` because the trait needs access to `getParameter` method.

Contributing
------------

[](#contributing)

To run the tests

```
./vendor/bin/php-cs-fixer fix
./vendor/bin/phpunit
./vendor/bin/phpstan analyse
```

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 92.7% 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 ~143 days

Recently: every ~329 days

Total

20

Last Release

1583d ago

Major Versions

1.0.0 → 2.0.02014-10-07

2.0.3 → 3.0.02015-03-02

3.2.2 → 4.0.02018-02-20

PHP version history (5 changes)1.0.0PHP &gt;=5.4

3.2.0PHP &gt;=5.5

4.6.0PHP &gt;=7.2

4.7.0PHP &gt;=7.2.5

4.8.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7039999f29a83140d61116032ec1684c752412e458ad1999e15eea2f8808498c?d=identicon)[mcfedr](/maintainers/mcfedr)

---

Top Contributors

[![mcfedr](https://avatars.githubusercontent.com/u/704356?v=4)](https://github.com/mcfedr "mcfedr (51 commits)")[![nonanerz](https://avatars.githubusercontent.com/u/19575167?v=4)](https://github.com/nonanerz "nonanerz (3 commits)")[![iangregory](https://avatars.githubusercontent.com/u/1449673?v=4)](https://github.com/iangregory "iangregory (1 commits)")

---

Tags

jsonsymfonyForms

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mcfedr-json-form/health.svg)

```
[![Health](https://phpackages.com/badges/mcfedr-json-form/health.svg)](https://phpackages.com/packages/mcfedr-json-form)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M373](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[kimai/kimai

Kimai - Time Tracking

4.7k8.7k1](/packages/kimai-kimai)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k50.1M314](/packages/api-platform-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[oro/platform

Business Application Platform (BAP)

642140.7k104](/packages/oro-platform)

PHPackages © 2026

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