{"id":15025723,"url":"https://github.com/better-serializer/better-serializer","last_synced_at":"2025-10-03T23:32:21.635Z","repository":{"id":55001618,"uuid":"95364813","full_name":"better-serializer/better-serializer","owner":"better-serializer","description":"General serializer for PHP. An alternative to JmsSerializer.","archived":true,"fork":false,"pushed_at":"2021-01-16T09:28:03.000Z","size":931,"stargazers_count":26,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-29T12:53:30.228Z","etag":null,"topics":["annotations","deserialization","fast","jackson","json","php","php71","serializer"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/better-serializer.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":"2017-06-25T14:28:34.000Z","updated_at":"2024-05-15T10:54:28.000Z","dependencies_parsed_at":"2022-08-14T08:40:49.130Z","dependency_job_id":null,"html_url":"https://github.com/better-serializer/better-serializer","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/better-serializer%2Fbetter-serializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/better-serializer%2Fbetter-serializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/better-serializer%2Fbetter-serializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/better-serializer%2Fbetter-serializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/better-serializer","download_url":"https://codeload.github.com/better-serializer/better-serializer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235204448,"owners_count":18952326,"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":["annotations","deserialization","fast","jackson","json","php","php71","serializer"],"created_at":"2024-09-24T20:02:54.317Z","updated_at":"2025-10-03T23:32:21.140Z","avatar_url":"https://github.com/better-serializer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BetterSerializer (PHP)\n\n[![Build Status](https://travis-ci.org/better-serializer/better-serializer.svg?branch=master)](https://travis-ci.org/better-serializer/better-serializer)\n[![Coverage Status](https://coveralls.io/repos/github/better-serializer/better-serializer/badge.svg?branch=master)](https://coveralls.io/github/better-serializer/better-serializer?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/better-serializer/better-serializer/version)](https://packagist.org/packages/better-serializer/better-serializer)\n[![Total Downloads](https://poser.pugx.org/better-serializer/better-serializer/downloads)](https://packagist.org/packages/better-serializer/better-serializer)\n[![Latest Unstable Version](https://poser.pugx.org/better-serializer/better-serializer/v/unstable)](//packagist.org/packages/better-serializer/better-serializer)\n[![License](https://poser.pugx.org/better-serializer/better-serializer/license)](https://packagist.org/packages/better-serializer/better-serializer)\n[![composer.lock available](https://poser.pugx.org/better-serializer/better-serializer/composerlock)](https://packagist.org/packages/better-serializer/better-serializer)\n[![Appveyor status](https://ci.appveyor.com/api/projects/status/github/better-serializer/better-serializer?svg=true)](https://ci.appveyor.com/api/projects/status/github/better-serializer/better-serializer)\n\nThis library provides a general serializer for PHP. Currently only JSON serialization format is supported.\nThe project aims to be an alternative to [JmsSerializer](https://github.com/schmittjoh/serializer). It tries\nto be faster then JmsSerializer and it also tries to sustain a better maintainable and understandable code base.\nAlso, as this is also a learning experiment, one of the goals is to have unit tests with 100% code coverage.\n\nExcept the above mentioned goals, the project also aims to provide some cool features - it tries to combine \nthe best features from JmsSerializer and from [Jackson](https://github.com/FasterXML/jackson) in Java.\n\n## Current state\n\nCurrently, only JSON de/serialization is implemented. It's possible to de/serialize complex nested data structures\n(objects and arrays). Only arrays are supported as collection types for now.\n\n## Performance\n\nFor now the code is only a proof of concept, but it is stabilizing more and more each day. \nIt already yields interesting results. Without implementing\nmetadata caching, the serialization process is already \n[4-6x faster](tests/Performance/Serialization/JsonTest.php) than using JmsSerializer. \nThe deserialization process is also faster, but only [cca 3.5x faster](tests/Performance/Deserialization/JsonTest.php).\n\nThere is also another benchmark, which compares JMS Serializer, [Ivory Serializer](https://github.com/egeloen/ivory-serializer) and Better Serialier. \nIt also integrates Symfony serializer, but I needed to comment it out, because it was 100-300x slower \nthan Better Serializer.\nYou can find a fork of it [here](https://github.com/better-serializer/ivory-serializer-benchmark) and try it \non your own. For best results, please disable XDebug while running the tests.\n\nHere are some of the results:\n\n```bash\n$ php bin/benchmark  --iteration 1000 --horizontal-complexity 2 --vertical-complexity 2\nIvory: Done!\nJMS: Done!\nBetterSerializer: Done!\n\n+------------------+----------------+--------+\n| Serializer       | Duration (sec) | Factor |\n+------------------+----------------+--------+\n| BetterSerializer | 0.001188s      | 1.00x  |\n| Ivory            | 0.002222s      | 1.87x  |\n| JMS              | 0.002901s      | 2.44x  |\n+------------------+----------------+--------+\n\n$ php bin/benchmark  --iteration 100 --horizontal-complexity 10 --vertical-complexity 10\nIvory: Done!\nJMS: Done!\nBetterSerializer: Done!\n\n+------------------+----------------+--------+\n| Serializer       | Duration (sec) | Factor |\n+------------------+----------------+--------+\n| BetterSerializer | 0.011377s      | 1.00x  |\n| Ivory            | 0.037377s      | 3.29x  |\n| JMS              | 0.046837s      | 4.12x  |\n+------------------+----------------+--------+\n\n$ php bin/benchmark  --iteration 1 --horizontal-complexity 100 --vertical-complexity 200\nIvory: Done!\nJMS: Done!\nBetterSerializer: Done!\n\n+------------------+----------------+--------+\n| Serializer       | Duration (sec) | Factor |\n+------------------+----------------+--------+\n| BetterSerializer | 1.040695s      | 1.00x  |\n| Ivory            | 4.191479s      | 4.03x  |\n| JMS              | 4.466160s      | 4.29x  |\n+------------------+----------------+--------+\n\n$ php bin/benchmark  --iteration 1 --horizontal-complexity 200 --vertical-complexity 200\nIvory: Done!\nJMS: Done!\nBetterSerializer: Done!\n\n+------------------+----------------+--------+\n| Serializer       | Duration (sec) | Factor |\n+------------------+----------------+--------+\n| BetterSerializer | 4.523851s      | 1.00x  |\n| Ivory            | 15.580491s     | 3.44x  |\n| JMS              | 18.571867s     | 4.11x  |\n+------------------+----------------+--------+\n```\n\n**This means that you can now effectively de/serialize 4x more entities (e.g. in API results) using the same \namount of time than before!**\n\nRegarding the performance gains - I'd like someone to check the measured values, since the results seem quite great\nand I'm suspicious myself :).\n\n## Features\n\nYou can check out the features in the [features page](doc/Features.md). Please also check the supported \n[annotations documentation](doc/Annotations.md).\n\n## Requirements\n\nThis library requires PHP 7.2 and it won't work with older versions. Older versions won't be supported.\n\n## Usage\n\nThe usage is described [here](doc/Usage.md).\n\nThe de/serializaton annotations are described [here](doc/Annotations.md).\n\nIf you'd like to write custom extensions for special de/serialising of selected data types, \ncheck the [extensions section](doc/Extensions.md)\n\n## Future Plans\n- ~~metadata caching~~\n- XML and YAML support\n- various collection classes support (~~Doctrine collections~~, internal PHP collections like SplStack)\n- data injection using class constructors (~~internal~~ and static), which should improve performance even more\n- various features import from JmsSerializer and Jackson\n- framework integrations\n\n**Contributions are welcome! :)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetter-serializer%2Fbetter-serializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetter-serializer%2Fbetter-serializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetter-serializer%2Fbetter-serializer/lists"}