PHPackages                             chrisyue/auto-json-response-bundle - 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. chrisyue/auto-json-response-bundle

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

chrisyue/auto-json-response-bundle
==================================

A Symfony bundle with a listener which converts controller returned data to a appropriate JsonResponse.

1.1.1(10y ago)14091MITPHPPHP &gt;=5.5

Since Mar 6Pushed 10y ago1 watchersCompare

[ Source](https://github.com/chrisyue/auto-json-response-bundle)[ Packagist](https://packagist.org/packages/chrisyue/auto-json-response-bundle)[ Docs](http://chrisyue.com)[ RSS](/packages/chrisyue-auto-json-response-bundle/feed)WikiDiscussions develop Synced 4w ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

Auto Json Response Bundle
=========================

[](#auto-json-response-bundle)

v1.1.1

A Symfony listener which converts controller result to a appropriate JsonResponse.

[![SensioLabsInsight](https://camo.githubusercontent.com/e8c328e22145dc69675fe5ffd472a9bb2ea2adebb1a836fa53db0c39ae23056f/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f32613063363037372d323534322d343166392d616332392d6338346566373233393737312f6269672e706e67)](https://insight.sensiolabs.com/projects/2a0c6077-2542-41f9-ac29-c84ef7239771)

[![Latest Stable Version](https://camo.githubusercontent.com/ae6df364f391f617dea94e7211e8133cefcea0471070010e5822b07b7c103552/68747470733a2f2f706f7365722e707567782e6f72672f63687269737975652f6175746f2d6a736f6e2d726573706f6e73652d62756e646c652f762f737461626c65)](https://packagist.org/packages/chrisyue/auto-json-response-bundle)[![License](https://camo.githubusercontent.com/bb065a80db7236a0babd7b6b7d13ca16af465e3cfb1d9ec7fa6a92099dc54c2f/68747470733a2f2f706f7365722e707567782e6f72672f63687269737975652f6175746f2d6a736f6e2d726573706f6e73652d62756e646c652f6c6963656e7365)](https://packagist.org/packages/chrisyue/auto-json-response-bundle)[![Build Status](https://camo.githubusercontent.com/d72709743d7b94b37945e4e1cc7361bea700429639f96e9ea2c5557e9ca2030a/68747470733a2f2f7472617669732d63692e6f72672f63687269737975652f6175746f2d6a736f6e2d726573706f6e73652d62756e646c652e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/chrisyue/auto-json-response-bundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/632909e42193fc633b37024b4754464e876e0f756c022255cec9afcb520adbdc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63687269737975652f6175746f2d6a736f6e2d726573706f6e73652d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/chrisyue/auto-json-response-bundle/?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/19e4d3cd42a0facaa307d647986c2ae78ccdcec219339f09b17a08259471763a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63687269737975652f6175746f2d6a736f6e2d726573706f6e73652d62756e646c652f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/chrisyue/auto-json-response-bundle/?branch=develop)[![StyleCI](https://camo.githubusercontent.com/432e775fae2d6c454e35d212ccd02f3568ff29060874609abdf549d6fc4fa746/68747470733a2f2f7374796c6563692e696f2f7265706f732f35323231323033312f736869656c64)](https://styleci.io/repos/52212031)

Features
--------

[](#features)

- Convert `null` to `JsonResponse(null, 204)`
- Convert `$array|$object` to `JsonResponse($array|$normalizedObject)`
- Convert `$array|$object` to `JsonResponse($array|$normalizedObject, 201)` if the method is `POST`

Installation
------------

[](#installation)

```
$ composer require chrisyue/auto-json-response-bundle

```

```
// AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Chrisyue\Bundle\AutoJsonResponseBundle\ChrisyueAutoJsonResponseBundle(),
    );
}
```

Usage
-----

[](#usage)

This bundle will take effect if the route `_format` parameter is set to `json`.

```
# in your route file:
api:
    resource: ...
    defaults:
        _format: json
```

or in your controller file when you use annotation

```
/**
 * @Route(...)
 */
public function putAction(Response $response, $_format = 'json')
{
    ...

    return $object;
}
```

or any other ways to set the `$_format` to `json`.

This bundle uses Symfony built-in serializer to normalize object, so the serialize feature should be enable if you want to deal with object:

```
# app/config/config.yml
framework:
    # ...
    serializer:
        enabled: true
```

with the power of the built-in serializer, we can do more configuration to meet our needs, like convert camalCase property to snake\_case:

```
# app/config/config.yml
framework:
    serializer:
        enable_annotations: true
        name_converter: serializer.name_converter.camel_case_to_snake_case
```

More information about serialize, just check [symfony official documentation](https://symfony.com/doc/current/cookbook/serializer.html)

After v1.1.0, this bundle support specify default serialization groups:

```
#app/config/config.yml
chrisyue_auto_json_response:
    serializer:
        default_groups:
            - 'group1'
            - 'group2'
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity62

Established project with proven stability

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 ~21 days

Total

4

Last Release

3702d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/866a89d263a74e8cb113cdb20fa90999b0340dbbddbf20503ec424c3c263369b?d=identicon)[chrisyue](/maintainers/chrisyue)

---

Tags

converts-controllerjsonjson-responselistenerphpserializersymfonysymfony-bundleresponsejson

### Embed Badge

![Health badge](/badges/chrisyue-auto-json-response-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/chrisyue-auto-json-response-bundle/health.svg)](https://phpackages.com/packages/chrisyue-auto-json-response-bundle)
```

PHPackages © 2026

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