{"id":20330740,"url":"https://github.com/chrisyue/auto-json-response-bundle","last_synced_at":"2026-05-06T13:13:32.235Z","repository":{"id":56952666,"uuid":"52212031","full_name":"chrisyue/auto-json-response-bundle","owner":"chrisyue","description":"A Symfony bundle with a listener which converts controller returned data into a appropriate JsonResponse.","archived":false,"fork":false,"pushed_at":"2016-05-26T08:35:21.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-01-14T15:23:47.566Z","etag":null,"topics":["converts-controller","json","json-response","listener","php","serializer","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrisyue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-21T15:08:18.000Z","updated_at":"2017-12-22T06:31:41.000Z","dependencies_parsed_at":"2022-08-21T04:10:15.986Z","dependency_job_id":null,"html_url":"https://github.com/chrisyue/auto-json-response-bundle","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyue%2Fauto-json-response-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyue%2Fauto-json-response-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyue%2Fauto-json-response-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyue%2Fauto-json-response-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisyue","download_url":"https://codeload.github.com/chrisyue/auto-json-response-bundle/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241851253,"owners_count":20030962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["converts-controller","json","json-response","listener","php","serializer","symfony","symfony-bundle"],"created_at":"2024-11-14T20:17:30.761Z","updated_at":"2026-05-06T13:13:27.212Z","avatar_url":"https://github.com/chrisyue.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Auto Json Response Bundle\n=========================\n\nv1.1.1\n\nA Symfony listener which converts controller result to a appropriate JsonResponse.\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/2a0c6077-2542-41f9-ac29-c84ef7239771/big.png)](https://insight.sensiolabs.com/projects/2a0c6077-2542-41f9-ac29-c84ef7239771)\n\n[![Latest Stable Version](https://poser.pugx.org/chrisyue/auto-json-response-bundle/v/stable)](https://packagist.org/packages/chrisyue/auto-json-response-bundle)\n[![License](https://poser.pugx.org/chrisyue/auto-json-response-bundle/license)](https://packagist.org/packages/chrisyue/auto-json-response-bundle)\n[![Build Status](https://travis-ci.org/chrisyue/auto-json-response-bundle.svg?branch=develop)](https://travis-ci.org/chrisyue/auto-json-response-bundle)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/chrisyue/auto-json-response-bundle/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/chrisyue/auto-json-response-bundle/?branch=develop)\n[![Code Coverage](https://scrutinizer-ci.com/g/chrisyue/auto-json-response-bundle/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/chrisyue/auto-json-response-bundle/?branch=develop)\n[![StyleCI](https://styleci.io/repos/52212031/shield)](https://styleci.io/repos/52212031)\n\nFeatures\n--------\n\n* Convert `null` to `JsonResponse(null, 204)`\n* Convert `$array|$object` to `JsonResponse($array|$normalizedObject)`\n* Convert `$array|$object` to `JsonResponse($array|$normalizedObject, 201)` if the method is `POST`\n\nInstallation\n------------\n\n```\n$ composer require chrisyue/auto-json-response-bundle\n```\n\n```php\n// AppKernel.php\n\npublic function registerBundles()\n{\n    $bundles = array(\n        // ...\n        new Chrisyue\\Bundle\\AutoJsonResponseBundle\\ChrisyueAutoJsonResponseBundle(),\n    );\n}\n```\n\nUsage\n-----\n\nThis bundle will take effect if the route `_format` parameter is set to `json`.\n\n```yaml\n# in your route file:\napi:\n    resource: ...\n    defaults:\n        _format: json\n```\n\nor in your controller file when you use annotation\n\n```php\n/**\n * @Route(...)\n */\npublic function putAction(Response $response, $_format = 'json')\n{\n    ...\n\n    return $object;\n}\n```\n\nor any other ways to set the `$_format` to `json`.\n\nThis bundle uses Symfony built-in serializer to normalize object, so the serialize feature should be enable if you want to deal with object:\n\n```yaml\n# app/config/config.yml\nframework:\n    # ...\n    serializer:\n        enabled: true\n```\n\nwith the power of the built-in serializer, we can do more configuration to meet our needs, like convert camalCase property to snake\\_case:\n\n```yaml\n# app/config/config.yml\nframework:\n    serializer:\n        enable_annotations: true\n        name_converter: serializer.name_converter.camel_case_to_snake_case\n```\n\nMore information about serialize, just check [symfony official documentation](https://symfony.com/doc/current/cookbook/serializer.html)\n\nAfter v1.1.0, this bundle support specify default serialization groups:\n\n```yaml\n#app/config/config.yml\nchrisyue_auto_json_response:\n    serializer:\n        default_groups:\n            - 'group1'\n            - 'group2'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyue%2Fauto-json-response-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisyue%2Fauto-json-response-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyue%2Fauto-json-response-bundle/lists"}