├── .yamllint.yaml ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── composer.json ├── config └── serializer.php ├── renovate.json └── src ├── Bridge └── Laravel │ ├── Facades │ ├── Manager.php │ └── Serializer.php │ ├── Http │ ├── HttpCode.php │ └── ResponseFactory.php │ └── Providers │ └── SerializerServiceProvider.php ├── Config.php ├── Contracts ├── ConfigRepository.php ├── EncoderRegistrationStrategy.php ├── EncoderRegistryInterface.php ├── NormalizerRegistrationStrategy.php ├── NormalizerRegistryInterface.php ├── SerializerException.php ├── SerializerInterface.php └── SerializerRegistryInterface.php ├── DefaultEncoderRegistrationStrategy.php ├── DefaultNormalizerRegistrationStrategy.php ├── EncoderRegistry.php ├── Exceptions ├── MissingRequiredAttributes.php └── SerializerNotFound.php ├── Manager ├── Serializer.php ├── SerializerManager.php └── SerializerRegistry.php ├── NormalizerRegistry.php └── Normalizers └── RamseyUuidNormalizer.php /.yamllint.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | extends: "default" 4 | 5 | ignore: | 6 | .build/ 7 | vendor/ 8 | 9 | # Overwrite above default rules 10 | rules: 11 | braces: 12 | # Defaults 13 | # min-spaces-inside: 0 14 | # max-spaces-inside: 0 15 | 16 | # Keep 0 min-spaces to not error on empty {} collection definitions 17 | min-spaces-inside: 0 18 | 19 | # Allow one space inside braces to improve code readability 20 | max-spaces-inside: 1 21 | 22 | brackets: 23 | # Defaults 24 | # min-spaces-inside: 0 25 | # max-spaces-inside: 0 26 | 27 | # Keep 0 min-spaces to not error on empty [] collection definitions 28 | min-spaces-inside: 0 29 | 30 | # Allow one space inside braces to improve code readability 31 | max-spaces-inside: 1 32 | 33 | colons: 34 | # Defaults 35 | # min-spaces-before: 0 36 | # max-spaces-after: 1 37 | 38 | # Allow multiple spaces after a colon to allow indentation of YAML 39 | # dictionary values 40 | max-spaces-after: -1 41 | 42 | commas: 43 | # Defaults 44 | # max-spaces-after: 1 45 | 46 | # Allow multiple spaces after a comma to allow indentation of YAML 47 | # dictionary values 48 | max-spaces-after: -1 49 | 50 | comments: 51 | require-starting-space: true 52 | min-spaces-from-content: 1 53 | 54 | yaml-files: 55 | - "*.yaml" 56 | - "*.yml" 57 | 58 | ... 59 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [3.0.0](https://github.com/wayofdev/laravel-symfony-serializer/compare/v2.1.1...v3.0.0) (2025-05-18) 4 | 5 | 6 | ### ⚠ BREAKING CHANGES 7 | 8 | * add Laravel 12 support ([#229](https://github.com/wayofdev/laravel-symfony-serializer/issues/229)) 9 | 10 | ### Features 11 | 12 | * add Laravel 12 support ([#229](https://github.com/wayofdev/laravel-symfony-serializer/issues/229)) ([84d8faa](https://github.com/wayofdev/laravel-symfony-serializer/commit/84d8faad5f52ea64de5063de7c08d254f9d412d9)) 13 | 14 | 15 | ### Documentation 16 | 17 | * update README.md ([ea23edb](https://github.com/wayofdev/laravel-symfony-serializer/commit/ea23edb1f6d166b0227984d6cced14cdb45bece2)) 18 | 19 | ## [2.1.1](https://github.com/wayofdev/laravel-symfony-serializer/compare/v2.1.0...v2.1.1) (2024-06-19) 20 | 21 | 22 | ### Bug Fixes 23 | 24 | * add static types to Serializer facade ([434e73b](https://github.com/wayofdev/laravel-symfony-serializer/commit/434e73baf6ead436c36a36c79d20fc96f222b46b)) 25 | 26 | 27 | ### Documentation 28 | 29 | * updating README.md ([1578cd9](https://github.com/wayofdev/laravel-symfony-serializer/commit/1578cd914556c768c91cab59a94e67e553b66557)) 30 | 31 | ## [2.1.0](https://github.com/wayofdev/laravel-symfony-serializer/compare/v2.0.0...v2.1.0) (2024-06-19) 32 | 33 | 34 | ### Features 35 | 36 | * add static types to Manager Facade ([c4dfdf8](https://github.com/wayofdev/laravel-symfony-serializer/commit/c4dfdf8ea1d91cd6401cd4ed6d72cee3e27c08bd)) 37 | 38 | ## [2.0.0](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.60...v2.0.0) (2024-06-18) 39 | 40 | 41 | ### ⚠ BREAKING CHANGES 42 | 43 | * prepare for release 2.0 44 | 45 | ### Features 46 | 47 | * add symfony serializer facade ([b0d0c04](https://github.com/wayofdev/laravel-symfony-serializer/commit/b0d0c0417f25cdb51048ef84fb5ef1c2b826e5ae)) 48 | * prepare for release 2.0 ([ca5ef98](https://github.com/wayofdev/laravel-symfony-serializer/commit/ca5ef989cc25152611d063f2fa8dffc3ca4552ef)) 49 | * support for laravel 11.x and symfony 7.x ([b05333d](https://github.com/wayofdev/laravel-symfony-serializer/commit/b05333d464805aa1dd535fec77662d0ff6dcbf9f)) 50 | 51 | 52 | ### Bug Fixes 53 | 54 | * remove database container support ([2e30104](https://github.com/wayofdev/laravel-symfony-serializer/commit/2e30104ed69ca6ce31ce9de5bed56d216f2c3343)) 55 | 56 | 57 | ### Dependencies 58 | 59 | * remove doctrine/annotations ([c694154](https://github.com/wayofdev/laravel-symfony-serializer/commit/c69415437573cbb4f4eb4b43257b29124f55eec7)) 60 | 61 | 62 | ### Code Refactoring 63 | 64 | * rewrote package to be more configurable and flexible ([32c3ceb](https://github.com/wayofdev/laravel-symfony-serializer/commit/32c3ceb10f8277c49d0aede645f962c3df30baae)) 65 | 66 | ## [1.2.60](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.59...v1.2.60) (2023-09-14) 67 | 68 | 69 | ### Miscellaneous 70 | 71 | * **deps:** update codecov/codecov-action action to v4 ([75d5901](https://github.com/wayofdev/laravel-symfony-serializer/commit/75d5901ba2ca0fb82abd940a3e1cdbf840c1597f)) 72 | 73 | ## [1.2.59](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.58...v1.2.59) (2023-09-14) 74 | 75 | 76 | ### Miscellaneous 77 | 78 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.60 ([913023a](https://github.com/wayofdev/laravel-symfony-serializer/commit/913023a4dcd4a2ae42b964e7b59ae0257831566d)) 79 | 80 | ## [1.2.58](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.57...v1.2.58) (2023-09-13) 81 | 82 | 83 | ### Miscellaneous 84 | 85 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.59 ([5898d71](https://github.com/wayofdev/laravel-symfony-serializer/commit/5898d719139e858adcad87b824fea99eb3e6a972)) 86 | 87 | ## [1.2.57](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.56...v1.2.57) (2023-09-13) 88 | 89 | 90 | ### Miscellaneous 91 | 92 | * **deps:** update dependency phpstan/phpstan to v1.10.34 ([31399b7](https://github.com/wayofdev/laravel-symfony-serializer/commit/31399b78f7351a5d3d07114e6c2ae742631cdf60)) 93 | 94 | ## [1.2.56](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.55...v1.2.56) (2023-09-12) 95 | 96 | 97 | ### Miscellaneous 98 | 99 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.58 ([d325b49](https://github.com/wayofdev/laravel-symfony-serializer/commit/d325b4943f81740c9baf7f5ffad67f25fa0134e6)) 100 | 101 | ## [1.2.55](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.54...v1.2.55) (2023-09-08) 102 | 103 | 104 | ### Miscellaneous 105 | 106 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.57 ([bccfb4e](https://github.com/wayofdev/laravel-symfony-serializer/commit/bccfb4edf9194544b6ed93bc22003e67eb02b0fc)) 107 | 108 | ## [1.2.54](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.53...v1.2.54) (2023-09-08) 109 | 110 | 111 | ### Miscellaneous 112 | 113 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.56 ([49fa654](https://github.com/wayofdev/laravel-symfony-serializer/commit/49fa65457cbdd66ad8cea8a2d9cf814337e7eabe)) 114 | 115 | ## [1.2.53](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.52...v1.2.53) (2023-09-04) 116 | 117 | 118 | ### Miscellaneous 119 | 120 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.54 ([40aa9c1](https://github.com/wayofdev/laravel-symfony-serializer/commit/40aa9c18280430791534f1d3d1d4bfc2807bda11)) 121 | 122 | ## [1.2.52](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.51...v1.2.52) (2023-09-04) 123 | 124 | 125 | ### Miscellaneous 126 | 127 | * **deps:** update actions/checkout action to v4 ([3bd2432](https://github.com/wayofdev/laravel-symfony-serializer/commit/3bd2432d03c6059991c4dfdb2148bce4ccfc01dc)) 128 | 129 | ## [1.2.51](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.50...v1.2.51) (2023-09-04) 130 | 131 | 132 | ### Miscellaneous 133 | 134 | * **deps:** update dependency phpstan/phpstan to v1.10.33 ([8bd3dd2](https://github.com/wayofdev/laravel-symfony-serializer/commit/8bd3dd28e5252938039e9e015bc85a804620e950)) 135 | 136 | ## [1.2.50](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.49...v1.2.50) (2023-09-04) 137 | 138 | 139 | ### Miscellaneous 140 | 141 | * **deps:** update dependency ergebnis/composer-normalize to v2.36.0 ([c6a80ae](https://github.com/wayofdev/laravel-symfony-serializer/commit/c6a80aeee13c899a96eb2e624d806c3df08b109e)) 142 | 143 | ## [1.2.49](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.48...v1.2.49) (2023-09-04) 144 | 145 | 146 | ### Miscellaneous 147 | 148 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.51 ([da600ce](https://github.com/wayofdev/laravel-symfony-serializer/commit/da600ceb4894226557957f45c447d8bf3300448a)) 149 | 150 | ## [1.2.48](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.47...v1.2.48) (2023-09-01) 151 | 152 | 153 | ### Miscellaneous 154 | 155 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.50 ([ee018eb](https://github.com/wayofdev/laravel-symfony-serializer/commit/ee018eb6e79b6d60173135d9c42915b0c71c1a48)) 156 | 157 | ## [1.2.47](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.46...v1.2.47) (2023-08-30) 158 | 159 | 160 | ### Miscellaneous 161 | 162 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.49 ([521a283](https://github.com/wayofdev/laravel-symfony-serializer/commit/521a283a54faaa068faf2f26b416d265407c9d97)) 163 | 164 | ## [1.2.46](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.45...v1.2.46) (2023-08-26) 165 | 166 | 167 | ### Miscellaneous 168 | 169 | * **deps:** update dependency orchestra/testbench to v8.9.1 ([22d47c8](https://github.com/wayofdev/laravel-symfony-serializer/commit/22d47c8ef4e93623d02438d687b46c6fa38a6d7b)) 170 | 171 | ## [1.2.45](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.44...v1.2.45) (2023-08-26) 172 | 173 | 174 | ### Bug Fixes 175 | 176 | * **deps:** update dependency symfony/serializer to v6.3.4 ([9027e5a](https://github.com/wayofdev/laravel-symfony-serializer/commit/9027e5ab01667d6fae428a31904cc77586ff82a5)) 177 | 178 | ## [1.2.44](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.43...v1.2.44) (2023-08-25) 179 | 180 | 181 | ### Miscellaneous 182 | 183 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.48 ([d82231c](https://github.com/wayofdev/laravel-symfony-serializer/commit/d82231c1d947df12d6e2359cc37c9dcd4e58d8d8)) 184 | 185 | ## [1.2.43](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.42...v1.2.43) (2023-08-25) 186 | 187 | 188 | ### Miscellaneous 189 | 190 | * **deps:** update dependency phpstan/phpstan-phpunit to v1.3.14 ([ee404ce](https://github.com/wayofdev/laravel-symfony-serializer/commit/ee404cee72539b379597b9df684375d3b197dee6)) 191 | 192 | ## [1.2.42](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.41...v1.2.42) (2023-08-24) 193 | 194 | 195 | ### Miscellaneous 196 | 197 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.47 ([63af2f5](https://github.com/wayofdev/laravel-symfony-serializer/commit/63af2f5b89780eadd552d60f25ce28ebec361da3)) 198 | 199 | ## [1.2.41](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.40...v1.2.41) (2023-08-24) 200 | 201 | 202 | ### Miscellaneous 203 | 204 | * **deps:** update dependency phpstan/phpstan to v1.10.32 ([10f8cff](https://github.com/wayofdev/laravel-symfony-serializer/commit/10f8cffe7bceda5196d0864deecca4ea85c786d6)) 205 | 206 | ## [1.2.40](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.39...v1.2.40) (2023-08-24) 207 | 208 | 209 | ### Miscellaneous 210 | 211 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.46 ([80dbcaf](https://github.com/wayofdev/laravel-symfony-serializer/commit/80dbcaf3a7850404b2a5de84122489a61fb25b82)) 212 | 213 | ## [1.2.39](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.38...v1.2.39) (2023-08-24) 214 | 215 | 216 | ### Miscellaneous 217 | 218 | * **deps:** update dependency phpstan/phpstan to v1.10.31 ([8f27919](https://github.com/wayofdev/laravel-symfony-serializer/commit/8f27919d03784fed49deb6f1a4bfc8f5d6b9404a)) 219 | 220 | ## [1.2.38](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.37...v1.2.38) (2023-08-22) 221 | 222 | 223 | ### Miscellaneous 224 | 225 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.45 ([8e53cc3](https://github.com/wayofdev/laravel-symfony-serializer/commit/8e53cc3d49cfe285a8640bef8afe65574cfa1625)) 226 | 227 | ## [1.2.37](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.36...v1.2.37) (2023-08-22) 228 | 229 | 230 | ### Miscellaneous 231 | 232 | * **deps:** update dependency phpstan/phpstan to v1.10.30 ([7f96b3e](https://github.com/wayofdev/laravel-symfony-serializer/commit/7f96b3e354e80272507a9861f98aaa7d69b8a642)) 233 | 234 | ## [1.2.36](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.35...v1.2.36) (2023-08-21) 235 | 236 | 237 | ### Miscellaneous 238 | 239 | * **deps:** update dependency pestphp/pest to v2.16.0 ([b6f57d4](https://github.com/wayofdev/laravel-symfony-serializer/commit/b6f57d4802c6eaca164d4cbcfa5e3eef3f9afe86)) 240 | 241 | ## [1.2.35](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.34...v1.2.35) (2023-08-21) 242 | 243 | 244 | ### Miscellaneous 245 | 246 | * **deps:** update dependency pestphp/pest to v2.15.0 ([879532f](https://github.com/wayofdev/laravel-symfony-serializer/commit/879532ff70562d638b1b0e3127cb83c83202dc38)) 247 | 248 | ## [1.2.34](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.33...v1.2.34) (2023-08-15) 249 | 250 | 251 | ### Miscellaneous 252 | 253 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.44 ([21c43a6](https://github.com/wayofdev/laravel-symfony-serializer/commit/21c43a640d0290622b06016edaad85377afc7c7f)) 254 | 255 | ## [1.2.33](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.32...v1.2.33) (2023-08-15) 256 | 257 | 258 | ### Miscellaneous 259 | 260 | * **deps:** update dependency phpunit/phpunit to v10.3.1 ([4aa379a](https://github.com/wayofdev/laravel-symfony-serializer/commit/4aa379ae603bf81185097afbafc184f6575f60cf)) 261 | 262 | ## [1.2.32](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.31...v1.2.32) (2023-08-14) 263 | 264 | 265 | ### Miscellaneous 266 | 267 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.43 ([1df143a](https://github.com/wayofdev/laravel-symfony-serializer/commit/1df143acc472fb2318a3bb807de7b5e638a3b68f)) 268 | 269 | ## [1.2.31](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.30...v1.2.31) (2023-08-14) 270 | 271 | 272 | ### Miscellaneous 273 | 274 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.42 ([7e91efd](https://github.com/wayofdev/laravel-symfony-serializer/commit/7e91efdda17eddaef2362ef7fff355759ae4226f)) 275 | 276 | ## [1.2.30](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.29...v1.2.30) (2023-08-14) 277 | 278 | 279 | ### Miscellaneous 280 | 281 | * **deps:** update dependency phpstan/phpstan to v1.10.29 ([8a0ecfc](https://github.com/wayofdev/laravel-symfony-serializer/commit/8a0ecfc5af86f4c0785da6bb959abfa41614ef89)) 282 | 283 | ## [1.2.29](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.28...v1.2.29) (2023-08-14) 284 | 285 | 286 | ### Miscellaneous 287 | 288 | * **deps:** update dependency pestphp/pest to v2.13.0 ([b0fbe50](https://github.com/wayofdev/laravel-symfony-serializer/commit/b0fbe50326680cb986cdbe5ff7491e16e7343a0b)) 289 | 290 | ## [1.2.28](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.27...v1.2.28) (2023-08-13) 291 | 292 | 293 | ### Miscellaneous 294 | 295 | * **deps:** update dependency phpunit/phpunit to v10.3.1 ([97cab54](https://github.com/wayofdev/laravel-symfony-serializer/commit/97cab545a3f7dfbda12dcdcae1efe1546cc9635a)) 296 | 297 | ## [1.2.27](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.26...v1.2.27) (2023-08-12) 298 | 299 | 300 | ### Miscellaneous 301 | 302 | * **deps:** update dependency pestphp/pest to v2.13.0 ([d5b5076](https://github.com/wayofdev/laravel-symfony-serializer/commit/d5b507609225d9ebfd4a15e7a173f57c707bf379)) 303 | 304 | ## [1.2.26](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.25...v1.2.26) (2023-08-11) 305 | 306 | 307 | ### Miscellaneous 308 | 309 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.41 ([619c53b](https://github.com/wayofdev/laravel-symfony-serializer/commit/619c53befb545e3b3af749309582e9ceb5ad3681)) 310 | 311 | ## [1.2.25](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.24...v1.2.25) (2023-08-11) 312 | 313 | 314 | ### Miscellaneous 315 | 316 | * **deps:** update dependency ergebnis/composer-normalize to v2.35.0 ([aa5bf8c](https://github.com/wayofdev/laravel-symfony-serializer/commit/aa5bf8c1ff6ae419992722fd8ee68c24ca2d3ebe)) 317 | 318 | ## [1.2.24](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.23...v1.2.24) (2023-08-09) 319 | 320 | 321 | ### Miscellaneous 322 | 323 | * **deps:** update dependency orchestra/testbench to v8.6.1 ([34fc73a](https://github.com/wayofdev/laravel-symfony-serializer/commit/34fc73a7f9178626514f8634d6f27eaca85d8baa)) 324 | 325 | ## [1.2.23](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.22...v1.2.23) (2023-08-08) 326 | 327 | 328 | ### Miscellaneous 329 | 330 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.40 ([038d374](https://github.com/wayofdev/laravel-symfony-serializer/commit/038d3745841b1525ab5e6b1954df0264e2f55c19)) 331 | 332 | ## [1.2.22](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.21...v1.2.22) (2023-08-08) 333 | 334 | 335 | ### Miscellaneous 336 | 337 | * **deps:** update dependency phpstan/phpstan to v1.10.28 ([ef04a45](https://github.com/wayofdev/laravel-symfony-serializer/commit/ef04a45f07d4b1dfa7a0d7a6f6cb9ea57992caad)) 338 | 339 | ## [1.2.21](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.20...v1.2.21) (2023-08-08) 340 | 341 | 342 | ### Miscellaneous 343 | 344 | * **deps:** update dependency orchestra/testbench to v8.6.0 ([16b8fda](https://github.com/wayofdev/laravel-symfony-serializer/commit/16b8fda1e4a7bf361d21cf801ec0d17b90c86356)) 345 | 346 | ## [1.2.20](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.19...v1.2.20) (2023-08-07) 347 | 348 | 349 | ### Miscellaneous 350 | 351 | * **deps:** update dependency pestphp/pest to v2.12.1 ([0e1c0a5](https://github.com/wayofdev/laravel-symfony-serializer/commit/0e1c0a56e01f9da6cdd5d4e07580c8d53afc8aba)) 352 | 353 | ## [1.2.19](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.18...v1.2.19) (2023-08-05) 354 | 355 | 356 | ### Miscellaneous 357 | 358 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.39 ([d9b4ea7](https://github.com/wayofdev/laravel-symfony-serializer/commit/d9b4ea794b0f644f2d73bd86e891d97edb204708)) 359 | 360 | ## [1.2.18](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.17...v1.2.18) (2023-08-05) 361 | 362 | 363 | ### Miscellaneous 364 | 365 | * **deps:** update dependency phpstan/phpstan to v1.10.27 ([56e2114](https://github.com/wayofdev/laravel-symfony-serializer/commit/56e2114534c363e8ee7a6fcdafa09487f026645e)) 366 | 367 | ## [1.2.17](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.16...v1.2.17) (2023-08-05) 368 | 369 | 370 | ### Miscellaneous 371 | 372 | * **deps:** update dependency phpstan/phpstan-deprecation-rules to v1.1.4 ([22dfa9d](https://github.com/wayofdev/laravel-symfony-serializer/commit/22dfa9df162fce83fd2c246717ab03b0df100cf5)) 373 | 374 | ## [1.2.16](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.15...v1.2.16) (2023-08-04) 375 | 376 | 377 | ### Miscellaneous 378 | 379 | * **deps:** update dependency pestphp/pest to v2.12.1 ([60158ff](https://github.com/wayofdev/laravel-symfony-serializer/commit/60158ff450c798c0e0b677ae715c3625c256d9ea)) 380 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.38 ([e291468](https://github.com/wayofdev/laravel-symfony-serializer/commit/e291468bf48d08122429d26fceb62c0d64106838)) 381 | 382 | ## [1.2.15](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.14...v1.2.15) (2023-08-04) 383 | 384 | 385 | ### Miscellaneous 386 | 387 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.37 ([cdcb133](https://github.com/wayofdev/laravel-symfony-serializer/commit/cdcb133b4d1b4730c2017afe7d40feaf65bef129)) 388 | 389 | ## [1.2.14](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.13...v1.2.14) (2023-08-03) 390 | 391 | 392 | ### Miscellaneous 393 | 394 | * **deps:** update dependency pestphp/pest to v2.12.0 ([9023911](https://github.com/wayofdev/laravel-symfony-serializer/commit/9023911cc5e8cb9d70251fc095473edbe6e0071d)) 395 | 396 | ## [1.2.13](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.12...v1.2.13) (2023-08-02) 397 | 398 | 399 | ### Miscellaneous 400 | 401 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.36 ([717a4f6](https://github.com/wayofdev/laravel-symfony-serializer/commit/717a4f60aa0f797280fd91d4a387dfd987906a5e)) 402 | 403 | ## [1.2.12](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.11...v1.2.12) (2023-08-01) 404 | 405 | 406 | ### Miscellaneous 407 | 408 | * **deps:** update dependency orchestra/testbench to v8.5.12 ([c6da0cc](https://github.com/wayofdev/laravel-symfony-serializer/commit/c6da0cc6558c4b21652878986bec4bd9309c751c)) 409 | 410 | ## [1.2.11](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.10...v1.2.11) (2023-08-01) 411 | 412 | 413 | ### Miscellaneous 414 | 415 | * **deps:** update dependency pestphp/pest to v2.11.0 ([a483e40](https://github.com/wayofdev/laravel-symfony-serializer/commit/a483e40b8232a73c1419dbc6ca90172120979c57)) 416 | 417 | ## [1.2.10](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.9...v1.2.10) (2023-07-31) 418 | 419 | 420 | ### Bug Fixes 421 | 422 | * **deps:** update symfony packages to v6.3.3 ([f2358c5](https://github.com/wayofdev/laravel-symfony-serializer/commit/f2358c5e3e43d2834acb9530d081e566fd592f37)) 423 | 424 | ## [1.2.9](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.8...v1.2.9) (2023-07-31) 425 | 426 | 427 | ### Miscellaneous 428 | 429 | * **deps:** update dependency pestphp/pest to v2.10.1 ([752de18](https://github.com/wayofdev/laravel-symfony-serializer/commit/752de18989d8c3b3662743389c5bf590587d2142)) 430 | 431 | ## [1.2.8](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.7...v1.2.8) (2023-07-31) 432 | 433 | 434 | ### Miscellaneous 435 | 436 | * **deps:** update dependency pestphp/pest to v2.10.0 ([8c44382](https://github.com/wayofdev/laravel-symfony-serializer/commit/8c443826d017f7ebd97fc6d86f3675b6a6425a98)) 437 | 438 | ## [1.2.7](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.6...v1.2.7) (2023-07-30) 439 | 440 | 441 | ### Bug Fixes 442 | 443 | * **deps:** update symfony packages to v6.3.2 ([2f23e02](https://github.com/wayofdev/laravel-symfony-serializer/commit/2f23e02c4eb787eca2295137af6ab7b30e2898b9)) 444 | 445 | ## [1.2.6](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.5...v1.2.6) (2023-07-30) 446 | 447 | 448 | ### Miscellaneous 449 | 450 | * **deps:** update dependency ergebnis/composer-normalize to v2.34.0 ([37b253d](https://github.com/wayofdev/laravel-symfony-serializer/commit/37b253db0d3111bf6e9d36251aaf124a6a5a60e3)) 451 | 452 | ## [1.2.5](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.4...v1.2.5) (2023-07-30) 453 | 454 | 455 | ### Miscellaneous 456 | 457 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.35 ([fab5e48](https://github.com/wayofdev/laravel-symfony-serializer/commit/fab5e48f8869e584d4526e4a4234be5a6b85b1ab)) 458 | 459 | ## [1.2.4](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.3...v1.2.4) (2023-07-30) 460 | 461 | 462 | ### Miscellaneous 463 | 464 | * **deps:** update dependency nunomaduro/larastan to v2.6.4 ([a52b7dd](https://github.com/wayofdev/laravel-symfony-serializer/commit/a52b7dd9a6cf86c99616d7484d2963e27fd3c4e9)) 465 | 466 | ## [1.2.3](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.2...v1.2.3) (2023-07-25) 467 | 468 | 469 | ### Miscellaneous 470 | 471 | * **deps:** update dependency orchestra/testbench to v8.5.11 ([fc2378e](https://github.com/wayofdev/laravel-symfony-serializer/commit/fc2378ed6d1c3a5542b138cbb8765bfd79a22dd5)) 472 | 473 | ## [1.2.2](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.1...v1.2.2) (2023-07-24) 474 | 475 | 476 | ### Miscellaneous 477 | 478 | * **deps:** update dependency pestphp/pest to v2.9.5 ([be635aa](https://github.com/wayofdev/laravel-symfony-serializer/commit/be635aaba47263670751fda24b1e29c7c209def7)) 479 | 480 | ## [1.2.1](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.2.0...v1.2.1) (2023-07-22) 481 | 482 | 483 | ### Miscellaneous 484 | 485 | * **deps:** update dependency pestphp/pest to v2.9.4 ([4c4f2fd](https://github.com/wayofdev/laravel-symfony-serializer/commit/4c4f2fd8e513eb5fa3cd2223bf4aa9bf22b38623)) 486 | 487 | ## [1.2.0](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.25...v1.2.0) (2023-07-22) 488 | 489 | 490 | ### Features 491 | 492 | * allow to pass custom normalizers, response factory is fluent now ([e62bda8](https://github.com/wayofdev/laravel-symfony-serializer/commit/e62bda838e2b67f68f26f20260260483eeac6fb9)) 493 | 494 | ## [1.1.25](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.24...v1.1.25) (2023-07-19) 495 | 496 | 497 | ### Miscellaneous 498 | 499 | * **deps:** update dependency pestphp/pest to v2.8.3 ([296ba5a](https://github.com/wayofdev/laravel-symfony-serializer/commit/296ba5ad4f4f42ed626cf677c52045c65e8220d9)) 500 | 501 | ## [1.1.24](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.23...v1.1.24) (2023-07-19) 502 | 503 | 504 | ### Miscellaneous 505 | 506 | * **deps:** update dependency phpstan/phpstan to v1.10.26 ([73e495b](https://github.com/wayofdev/laravel-symfony-serializer/commit/73e495b7789ef8d1a6e6ad5dfbc850ce0e4bb7a8)) 507 | 508 | ## [1.1.23](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.22...v1.1.23) (2023-07-19) 509 | 510 | 511 | ### Miscellaneous 512 | 513 | * **deps:** update dependency phpunit/phpunit to v10.2.6 ([9205a2c](https://github.com/wayofdev/laravel-symfony-serializer/commit/9205a2c692f1ee6d801de41dcb35d826a2415803)) 514 | 515 | ## [1.1.22](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.21...v1.1.22) (2023-07-12) 516 | 517 | 518 | ### Miscellaneous 519 | 520 | * **deps:** update dependency pestphp/pest to v2.8.2 ([44dc814](https://github.com/wayofdev/laravel-symfony-serializer/commit/44dc814ab290262663c3d3aff7f9f170742e55bd)) 521 | 522 | ## [1.1.21](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.20...v1.1.21) (2023-07-11) 523 | 524 | 525 | ### Miscellaneous 526 | 527 | * **deps:** update dependency orchestra/testbench to v8.5.10 ([6a6f227](https://github.com/wayofdev/laravel-symfony-serializer/commit/6a6f227f25d907e4c5e9292164b6b45517dabdae)) 528 | 529 | ## [1.1.20](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.19...v1.1.20) (2023-07-09) 530 | 531 | 532 | ### Miscellaneous 533 | 534 | * **deps:** update dependency ergebnis/composer-normalize to v2.33.0 ([49f0d71](https://github.com/wayofdev/laravel-symfony-serializer/commit/49f0d71ae2ecde3d810fcb10fed505dc082b99dd)) 535 | 536 | ## [1.1.19](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.18...v1.1.19) (2023-07-06) 537 | 538 | 539 | ### Miscellaneous 540 | 541 | * **deps:** update dependency phpstan/phpstan to v1.10.25 ([cc8a8f4](https://github.com/wayofdev/laravel-symfony-serializer/commit/cc8a8f41ae4c520f12b80ab40ba4ae932c0f56f3)) 542 | 543 | ## [1.1.18](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.17...v1.1.18) (2023-07-05) 544 | 545 | 546 | ### Miscellaneous 547 | 548 | * **deps:** update dependency phpstan/phpstan to v1.10.24 ([ca602b9](https://github.com/wayofdev/laravel-symfony-serializer/commit/ca602b9d4b0c15dcc97305f5e5c671974e079af4)) 549 | 550 | ## [1.1.17](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.16...v1.1.17) (2023-07-04) 551 | 552 | 553 | ### Miscellaneous 554 | 555 | * **deps:** update dependency phpstan/phpstan to v1.10.23 ([3cf3cc7](https://github.com/wayofdev/laravel-symfony-serializer/commit/3cf3cc7df89f6f4a5a8afe19d37c201332b2e31f)) 556 | 557 | ## [1.1.16](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.15...v1.1.16) (2023-07-01) 558 | 559 | 560 | ### Miscellaneous 561 | 562 | * **deps:** update dependency pestphp/pest to v2.8.2 ([a750ff4](https://github.com/wayofdev/laravel-symfony-serializer/commit/a750ff432d52b5f544fe4c6016ffa50e5a9d141c)) 563 | 564 | ## [1.1.15](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.14...v1.1.15) (2023-06-30) 565 | 566 | 567 | ### Miscellaneous 568 | 569 | * **deps:** update dependency phpstan/phpstan to v1.10.22 ([9d71492](https://github.com/wayofdev/laravel-symfony-serializer/commit/9d71492e2e29a4cefc85827bebaa5f27cb3e4e85)) 570 | 571 | ## [1.1.14](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.13...v1.1.14) (2023-06-30) 572 | 573 | 574 | ### Miscellaneous 575 | 576 | * **deps:** update dependency ergebnis/composer-normalize to v2.32.0 ([3cfe5ef](https://github.com/wayofdev/laravel-symfony-serializer/commit/3cfe5ef2103253092df0aa143662b4626b992781)) 577 | 578 | ## [1.1.13](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.12...v1.1.13) (2023-06-30) 579 | 580 | 581 | ### Miscellaneous 582 | 583 | * **deps:** update dependency phpunit/phpunit to v10.2.3 ([01a0d3d](https://github.com/wayofdev/laravel-symfony-serializer/commit/01a0d3d7b54ca8aacb23d0f8d976a7f5ab14f012)) 584 | 585 | ## [1.1.12](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.11...v1.1.12) (2023-06-27) 586 | 587 | 588 | ### Miscellaneous 589 | 590 | * **deps:** update dependency orchestra/testbench to v8.5.9 ([b735a47](https://github.com/wayofdev/laravel-symfony-serializer/commit/b735a47545ac0fba5110632454335820ef1c6ff2)) 591 | 592 | ## [1.1.11](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.10...v1.1.11) (2023-06-26) 593 | 594 | 595 | ### Bug Fixes 596 | 597 | * **deps:** update dependency symfony/serializer to v6.3.1 ([82f45a0](https://github.com/wayofdev/laravel-symfony-serializer/commit/82f45a095df54804ab086b3e1ecff6c33730079f)) 598 | 599 | ## [1.1.10](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.9...v1.1.10) (2023-06-25) 600 | 601 | 602 | ### Miscellaneous 603 | 604 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.19 ([f0bea44](https://github.com/wayofdev/laravel-symfony-serializer/commit/f0bea44d8885c945f272d8e5384bf1b979656eaf)) 605 | 606 | ## [1.1.9](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.8...v1.1.9) (2023-06-24) 607 | 608 | 609 | ### Miscellaneous 610 | 611 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.18 ([4076bf3](https://github.com/wayofdev/laravel-symfony-serializer/commit/4076bf3526fa5ca094dbdd4be1fcdc787f4b1512)) 612 | 613 | ## [1.1.8](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.7...v1.1.8) (2023-06-24) 614 | 615 | 616 | ### Miscellaneous 617 | 618 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.17 ([f34fa56](https://github.com/wayofdev/laravel-symfony-serializer/commit/f34fa565789fff7c0568d024811f17b65b2b1370)) 619 | 620 | ## [1.1.7](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.6...v1.1.7) (2023-06-22) 621 | 622 | 623 | ### Miscellaneous 624 | 625 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.16 ([03b6024](https://github.com/wayofdev/laravel-symfony-serializer/commit/03b60240e88a0ff2708cddda196a000800c0bed6)) 626 | 627 | ## [1.1.6](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.5...v1.1.6) (2023-06-21) 628 | 629 | 630 | ### Miscellaneous 631 | 632 | * **deps:** update dependency phpstan/phpstan to v1.10.21 ([834e285](https://github.com/wayofdev/laravel-symfony-serializer/commit/834e285dfbdfd3953e6f670275098fb8ab1309b1)) 633 | 634 | ## [1.1.5](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.4...v1.1.5) (2023-06-20) 635 | 636 | 637 | ### Miscellaneous 638 | 639 | * **deps:** update dependency wayofdev/cs-fixer-config to v1.2.15 ([bd73aa4](https://github.com/wayofdev/laravel-symfony-serializer/commit/bd73aa492034a3e46a7832ab9513ea81c4feacc6)) 640 | 641 | ## [1.1.4](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.3...v1.1.4) (2023-06-20) 642 | 643 | 644 | ### Miscellaneous 645 | 646 | * **deps:** update dependency phpstan/phpstan to v1.10.20 ([62cce12](https://github.com/wayofdev/laravel-symfony-serializer/commit/62cce120359fbb0ff0fa1aaddc22e426f9898e4f)) 647 | 648 | ## [1.1.3](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.2...v1.1.3) (2023-06-20) 649 | 650 | 651 | ### Miscellaneous 652 | 653 | * **deps:** update dependency pestphp/pest to v2.8.1 ([785bbbb](https://github.com/wayofdev/laravel-symfony-serializer/commit/785bbbb72ab8932208fd72ad21d5c84e03a8c299)) 654 | 655 | ## [1.1.2](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.1...v1.1.2) (2023-06-19) 656 | 657 | 658 | ### Bug Fixes 659 | 660 | * serialization error of serializer.php config when applying laravel config cache ([f18c00d](https://github.com/wayofdev/laravel-symfony-serializer/commit/f18c00dbd6f4bddcf32bd3b6da7400c09680652e)) 661 | 662 | ## [1.1.1](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.1.0...v1.1.1) (2023-06-19) 663 | 664 | 665 | ### Miscellaneous 666 | 667 | * **deps:** update dependency nunomaduro/larastan to v2.6.3 ([bec3726](https://github.com/wayofdev/laravel-symfony-serializer/commit/bec3726890df62e3a10de972a06560a32316b76f)) 668 | 669 | ## [1.1.0](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.0.3...v1.1.0) (2023-06-11) 670 | 671 | 672 | ### Features 673 | 674 | * remove symfony/http-foundation dependency ([1b22a16](https://github.com/wayofdev/laravel-symfony-serializer/commit/1b22a167fc0892c77c1ba28503fc4edbfc6e52ef)) 675 | 676 | ## [1.0.3](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.0.2...v1.0.3) (2023-06-11) 677 | 678 | 679 | ### Bug Fixes 680 | 681 | * wrong response class returned by response factory ([3ff9318](https://github.com/wayofdev/laravel-symfony-serializer/commit/3ff9318403c5fb17945954a769d95fa2bf2bf9d9)) 682 | 683 | ## [1.0.2](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.0.1...v1.0.2) (2023-06-11) 684 | 685 | 686 | ### Documentation 687 | 688 | * add usage examples ([89ecfa9](https://github.com/wayofdev/laravel-symfony-serializer/commit/89ecfa924d99b4665f2aa28b7580a078d13ca1ef)) 689 | 690 | ## [1.0.1](https://github.com/wayofdev/laravel-symfony-serializer/compare/v1.0.0...v1.0.1) (2023-06-11) 691 | 692 | 693 | ### Documentation 694 | 695 | * change readme ([ed9fe32](https://github.com/wayofdev/laravel-symfony-serializer/commit/ed9fe320bd481c0d922638650b0b199118ae9ec4)) 696 | 697 | ## 1.0.0 (2023-06-11) 698 | 699 | 700 | ### Features 701 | 702 | * initial commit ([c224a1c](https://github.com/wayofdev/laravel-symfony-serializer/commit/c224a1ca4e747592d3cdedd1f937003cea9fab4b)) 703 | * response interface and new tests ([675062b](https://github.com/wayofdev/laravel-symfony-serializer/commit/675062bfb73c16ffe4147a7b09bf15386ea65623)) 704 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022 "lotyp, Andrij Orlenko" 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
3 | 4 | 5 | 6 | WayOfDev Logo 7 | 8 | 9 |
10 |

11 | 12 |

13 | Build
14 | Build Status 15 |

16 |

17 | Project
18 | Total Downloads 19 | Latest Stable Version 20 | Commits since latest release 21 | PHP Version Require 22 |

23 |

24 | Quality
25 | Codecov 26 | Mutation testing badge 27 | PHP Stan Level 6 of 9 28 |

29 |

30 | Community
31 | Discord 32 | Follow on Twitter (X) 33 |

34 | 35 |
36 | 37 | # Laravel Symfony Serializer 38 | 39 | This package integrates the Symfony Serializer component into Laravel, providing a powerful tool for serializing and deserializing objects into various formats such as JSON, XML, CSV, and YAML. 40 | 41 | Detailed documentation on the Symfony Serializer can be found on their [official page](https://symfony.com/doc/current/components/serializer.html). 42 | 43 |
44 | 45 | ## 🗂️ Table of Contents 46 | 47 | - [Purpose](#-purpose) 48 | - [Installation](#-installation) 49 | - [Configuration](#-configuration) 50 | - [Configuration Options](#-configuration-options) 51 | - [Custom Strategies](#-custom-strategies) 52 | - [Usage](#-usage) 53 | - [Components](#-components) 54 | - [Example DTO](#-example-dto) 55 | - [Using `SerializerManager` in your Service Classes](#-using-serializermanager-in-service-classes) 56 | - [Using `ResponseFactory` in Laravel Controllers](#-using-responsefactory-in-laravel-controllers) 57 | - [Using in Laravel Queues](#-using-in-laravel-queues) 58 | - [Security Policy](#-security-policy) 59 | - [Want to Contribute?](#-want-to-contribute) 60 | - [Contributors](#-contributors) 61 | - [Social Links](#-social-links) 62 | - [License](#-license) 63 | - [Credits and Useful Resources](#-credits-and-useful-resources) 64 | 65 |
66 | 67 | ## 🤔 Purpose 68 | 69 | This package brings the power of the Symfony Serializer component to Laravel. While Laravel does not have a built-in serializer and typically relies on array or JSON transformations, this package provides more advanced serialization capabilities. These include object normalization, handling of circular references, property grouping, and format-specific encoders. 70 | 71 | If you are building a REST API, working with queues, or have complex serialization needs, this package will be especially useful. It allows you to use objects as payloads instead of simple arrays and supports various formats such as JSON, XML, CSV, and YAML. This documentation will guide you through the installation process and provide examples of how to use the package to serialize and deserialize your objects. 72 | 73 |
74 | 75 | 🙏 If you find this repository useful, please consider giving it a ⭐️. Thank you! 76 | 77 |
78 | 79 | ## 💿 Installation 80 | 81 | Require the package as a dependency: 82 | 83 | ```bash 84 | composer require wayofdev/laravel-symfony-serializer 85 | ``` 86 | 87 | You can publish the config file with: 88 | 89 | ```bash 90 | $ php artisan vendor:publish \ 91 | --provider="WayOfDev\Serializer\Bridge\Laravel\Providers\SerializerServiceProvider" \ 92 | --tag="config" 93 | ``` 94 | 95 |
96 | 97 | ## 🔧 Configuration 98 | 99 | The package configuration file allows you to customize various aspects of the serialization process. 100 | 101 | Below is the default configuration provided by the package: 102 | 103 | ```php 104 | , 119 | * encoderRegistrationStrategy: class-string, 120 | * metadataLoader: class-string|null, 121 | * } 122 | */ 123 | return [ 124 | 'default' => env('SERIALIZER_DEFAULT_FORMAT', 'symfony-json'), 125 | 126 | 'debug' => env('SERIALIZER_DEBUG_MODE', env('APP_DEBUG', false)), 127 | 128 | 'normalizerRegistrationStrategy' => DefaultNormalizerRegistrationStrategy::class, 129 | 130 | 'encoderRegistrationStrategy' => DefaultEncoderRegistrationStrategy::class, 131 | 132 | 'metadataLoader' => null, 133 | ]; 134 | ``` 135 | 136 | ### → Configuration Options 137 | 138 | - **`default`**: Specifies the default serializer format. This can be overridden by setting the `SERIALIZER_DEFAULT_FORMAT` environment variable. The default is `symfony-json`. 139 | - **`debug`**: Enables debug mode for `ProblemNormalizer`. This can be set using the `SERIALIZER_DEBUG_MODE` environment variable. It defaults to the `APP_DEBUG` value. 140 | - **`normalizerRegistrationStrategy`**: Specifies the strategy class for registering normalizers. The default strategy is [`WayOfDev\Serializer\DefaultNormalizerRegistrationStrategy`](https://github.com/wayofdev/laravel-symfony-serializer/blob/master/src/DefaultNormalizerRegistrationStrategy.php). 141 | - **`encoderRegistrationStrategy`**: Specifies the strategy class for registering encoders. The default strategy is [`WayOfDev\Serializer\DefaultEncoderRegistrationStrategy`](https://github.com/wayofdev/laravel-symfony-serializer/blob/master/src/DefaultEncoderRegistrationStrategy.php). 142 | - **`metadataLoader`**: Allows registration of a custom metadata loader. By default, `Symfony\Component\Serializer\Mapping\Loader\AttributeLoader` is used. 143 | 144 | ### → Custom Strategies 145 | 146 | [Due to Laravel's caching limitations, where configs cannot instantiate objects](https://elliotderhay.com/blog/caching-laravel-configs-that-use-objects), this package uses strategies to register normalizers and encoders. 147 | 148 | You can create custom normalizer or encoder registration strategies by implementing the respective interfaces. 149 | 150 | #### Normalizer Registration Strategy 151 | 152 | To create a custom normalizer registration strategy: 153 | 154 | 1. Implement the [`NormalizerRegistrationStrategy`](https://github.com/wayofdev/laravel-symfony-serializer/blob/master/src/Contracts/NormalizerRegistrationStrategy.php) interface: 155 | 156 | ```php 157 | }> 180 | */ 181 | public function normalizers(): iterable 182 | { 183 | // ... 184 | } 185 | } 186 | ``` 187 | 188 | 2. Change `serializer.php` config to use your custom strategy: 189 | 190 | ```php 191 | 'normalizerRegistrationStrategy' => CustomNormalizerRegistrationStrategy::class, 192 | ``` 193 | 194 | #### Encoder Registration Strategy 195 | 196 | To create a custom encoder registration strategy: 197 | 198 | 1. Implement the [`EncoderRegistrationStrategy`](https://github.com/wayofdev/laravel-symfony-serializer/blob/master/src/Contracts/EncoderRegistrationStrategy.php) interface: 199 | 200 | ```php 201 | 218 | */ 219 | public function encoders(): iterable 220 | { 221 | // Register your encoders here... 222 | 223 | yield ['encoder' => new Encoder\JsonEncoder()]; 224 | yield ['encoder' => new Encoder\CsvEncoder()]; 225 | yield ['encoder' => new Encoder\XmlEncoder()]; 226 | 227 | if (class_exists(Dumper::class)) { 228 | yield ['encoder' => new Encoder\YamlEncoder()]; 229 | } 230 | } 231 | } 232 | ``` 233 | 234 | 2. Change `serializer.php` config to use your custom strategy: 235 | 236 | ```php 237 | 'encoderRegistrationStrategy' => CustomEncoderRegistrationStrategy::class, 238 | ``` 239 | 240 |
241 | 242 | ## 💻 Usage 243 | 244 | The package provides a list of serializers that can be used to serialize and deserialize objects. 245 | 246 | The default serializers available in this package are: `symfony-json`, `symfony-csv`, `symfony-xml`, `symfony-yaml`. 247 | 248 | > [!WARNING] 249 | > The `yaml` encoder requires the `symfony/yaml` package and is disabled when the package is not installed. 250 | > Install the `symfony/yaml` package, and the encoder will be automatically enabled. 251 | 252 | ### → Components 253 | 254 | #### SerializerManager 255 | 256 | The `SerializerManager` handles the different serializers available in this package. It can be used to serialize and deserialize objects. 257 | 258 | #### ResponseFactory 259 | 260 | The `ResponseFactory` is used to create responses in Laravel controllers, making it easy to include serialized data in HTTP responses. 261 | 262 | #### Facades 263 | 264 | This package includes two Laravel Facades: 265 | 266 | - `Manager` — To access the underlying `SerializerManager` 267 | - `Serializer` — To access the bound and configured original Symfony Serializer instance. 268 | 269 | ### → Example DTO 270 | 271 | We will use this example DTO for serialization purposes: 272 | 273 | ```php 274 | id = $id; 298 | $this->name = $name; 299 | $this->email = $email; 300 | } 301 | 302 | public function id(): int 303 | { 304 | return $this->id; 305 | } 306 | 307 | public function name(): string 308 | { 309 | return $this->name; 310 | } 311 | 312 | public function email(): string 313 | { 314 | return $this->email; 315 | } 316 | } 317 | ``` 318 | 319 | ### → Using `SerializerManager` in Service Classes 320 | 321 | ```php 322 | serializer->serializer('symfony-json'); 339 | $dto = new UserDTO(1, 'John Doe', 'john@example.com'); 340 | 341 | $serialized = $serializer->serialize( 342 | payload: $dto, 343 | context: ['groups' => ['private']] 344 | ); 345 | } 346 | } 347 | ``` 348 | 349 | ### → Using `ResponseFactory` in Laravel Controllers 350 | 351 | Here's an example of how you can use the `ResponseFactory` in a Laravel Controller: 352 | 353 | **Example Controller:** 354 | 355 | ```php 356 | response->withContext(['groups' => ['private']]); 376 | $this->response->withStatusCode(HttpCode::HTTP_OK); 377 | 378 | return $this->response->create($dto); 379 | } 380 | } 381 | ``` 382 | 383 |
384 | 385 | ### → Using in Laravel Queues 386 | 387 | To switch from Laravel's default serialization to this implementation in queues, you can override the `__serialize` and `__unserialize` methods in your queue jobs. Here’s an example: 388 | 389 | ```php 390 | product = $product; 417 | } 418 | 419 | public function handle(ProductProcessor $processor): void 420 | { 421 | $processor->process($this->product); 422 | } 423 | 424 | public function __serialize(): array 425 | { 426 | return [ 427 | 'product' => Manager::serialize($this->product), 428 | ]; 429 | } 430 | 431 | public function __unserialize(array $values): void 432 | { 433 | $this->product = Manager::deserialize($values['product'], Product::class); 434 | } 435 | } 436 | ``` 437 | 438 |
439 | 440 | ## 🔒 Security Policy 441 | 442 | This project has a [security policy](.github/SECURITY.md). 443 | 444 |
445 | 446 | ## 🙌 Want to Contribute? 447 | 448 | Thank you for considering contributing to the wayofdev community! We welcome all kinds of contributions. If you want to: 449 | 450 | - 🤔 [Suggest a feature](https://github.com/wayofdev/laravel-symfony-serializer/issues/new?assignees=&labels=type%3A+enhancement&projects=&template=2-feature-request.yml&title=%5BFeature%5D%3A+) 451 | - 🐛 [Report an issue](https://github.com/wayofdev/laravel-symfony-serializer/issues/new?assignees=&labels=type%3A+documentation%2Ctype%3A+maintenance&projects=&template=1-bug-report.yml&title=%5BBug%5D%3A+) 452 | - 📖 [Improve documentation](https://github.com/wayofdev/laravel-symfony-serializer/issues/new?assignees=&labels=type%3A+documentation%2Ctype%3A+maintenance&projects=&template=4-docs-bug-report.yml&title=%5BDocs%5D%3A+) 453 | - 👨‍💻 [Contribute to the code](.github/CONTRIBUTING.md) 454 | 455 | You are more than welcome. Before contributing, please check our [contribution guidelines](.github/CONTRIBUTING.md). 456 | 457 | [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge)](https://conventionalcommits.org) 458 | 459 |
460 | 461 | ## 🫡 Contributors 462 | 463 |

464 | 465 | Contributors Badge 466 | 467 |
468 |
469 |

470 | 471 | ## 🌐 Social Links 472 | 473 | - **Twitter:** Follow our organization [@wayofdev](https://twitter.com/intent/follow?screen_name=wayofdev) and the author [@wlotyp](https://twitter.com/intent/follow?screen_name=wlotyp). 474 | - **Discord:** Join our community on [Discord](https://discord.gg/CE3TcCC5vr). 475 | 476 |
477 | 478 | ## 📜 License 479 | 480 | [![License](https://img.shields.io/github/license/wayofdev/laravel-symfony-serializer?style=for-the-badge&color=blue)](./LICENSE.md) 481 | 482 |
483 | 484 | ## 🧱 Credits and Useful Resources 485 | 486 | This repository is inspired by the following projects: 487 | 488 | - [spiral/serializer](https://github.com/spiral/serializer) 489 | - [spiral-packages/symfony-serializer](https://github.com/spiral-packages/symfony-serializer) 490 | - [jeromegamez/ramsey-uuid-normalizer](https://github.com/jeromegamez/ramsey-uuid-normalizer) 491 | - [wayofdev/laravel-jms-serializer](https://github.com/wayofdev/laravel-jms-serializer) 492 | - [symfony/serializer](https://github.com/symfony/serializer) 493 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wayofdev/laravel-symfony-serializer", 3 | "description": "📦 Laravel wrapper around Symfony Serializer.", 4 | "license": "MIT", 5 | "type": "library", 6 | "keywords": [ 7 | "php", 8 | "api", 9 | "laravel-package", 10 | "json", 11 | "php8", 12 | "laravel", 13 | "serializer", 14 | "symfony-component", 15 | "serialize", 16 | "laravel-api", 17 | "symfony-serializer", 18 | "laravel-serializer" 19 | ], 20 | "authors": [ 21 | { 22 | "name": "Andrij Orlenko", 23 | "email": "the@wayof.dev" 24 | } 25 | ], 26 | "homepage": "https://wayof.dev", 27 | "support": { 28 | "issues": "https://github.com/wayofdev/laravel-symfony-serializer/issues", 29 | "source": "https://github.com/wayofdev/laravel-symfony-serializer", 30 | "security": "https://github.com/wayofdev/laravel-symfony-serializer/blob/master/.github/SECURITY.md" 31 | }, 32 | "require": { 33 | "php": "^8.2", 34 | "illuminate/contracts": "^11.0 || ^12.0", 35 | "illuminate/http": "^11.0 || ^12.0", 36 | "illuminate/support": "^11.0 || ^12.0", 37 | "ramsey/uuid": "^4.7", 38 | "symfony/property-access": "^7.1", 39 | "symfony/property-info": "^7.1", 40 | "symfony/serializer": "^7.1" 41 | }, 42 | "require-dev": { 43 | "ergebnis/phpunit-slow-test-detector": "^2.19", 44 | "larastan/larastan": "^2.11", 45 | "orchestra/testbench": "^9.14", 46 | "pestphp/pest": "^2.36", 47 | "pestphp/pest-plugin-laravel": "^2.4", 48 | "phpstan/extension-installer": "^1.4", 49 | "phpstan/phpstan": "^1.12", 50 | "phpstan/phpstan-deprecation-rules": "^1.2", 51 | "phpstan/phpstan-phpunit": "^1.4", 52 | "phpstan/phpstan-strict-rules": "^1.6", 53 | "phpunit/phpunit": "^10.5", 54 | "psalm/plugin-laravel": "^2.12", 55 | "psalm/plugin-phpunit": "^0.19", 56 | "rector/rector": "^1.2", 57 | "roave/infection-static-analysis-plugin": "^1.35", 58 | "symfony/yaml": "^7.1", 59 | "vimeo/psalm": "^5.24", 60 | "wayofdev/cs-fixer-config": "^1.5" 61 | }, 62 | "suggest": { 63 | "symfony/yaml": "Required only if YamlEncoder support is needed." 64 | }, 65 | "autoload": { 66 | "psr-4": { 67 | "WayOfDev\\Serializer\\": "src/" 68 | } 69 | }, 70 | "autoload-dev": { 71 | "psr-4": { 72 | "WayOfDev\\App\\": "tests/app/", 73 | "WayOfDev\\Tests\\": "tests/src/" 74 | } 75 | }, 76 | "config": { 77 | "allow-plugins": { 78 | "ergebnis/composer-normalize": true, 79 | "infection/extension-installer": true, 80 | "pestphp/pest-plugin": true, 81 | "phpstan/extension-installer": true 82 | }, 83 | "audit": { 84 | "abandoned": "report" 85 | }, 86 | "platform": { 87 | "php": "8.2.17" 88 | }, 89 | "sort-packages": true 90 | }, 91 | "extra": { 92 | "composer-normalize": { 93 | "indent-size": 4, 94 | "indent-style": "space" 95 | }, 96 | "laravel": { 97 | "providers": [ 98 | "WayOfDev\\Serializer\\Bridge\\Laravel\\Providers\\SerializerServiceProvider" 99 | ] 100 | } 101 | }, 102 | "scripts": { 103 | "cs:diff": "php-cs-fixer fix --dry-run -v --diff", 104 | "cs:fix": "php-cs-fixer fix -v", 105 | "infect": [ 106 | "@putenv XDEBUG_MODE=coverage", 107 | "roave-infection-static-analysis-plugin" 108 | ], 109 | "infect:ci": [ 110 | "@putenv XDEBUG_MODE=coverage", 111 | "roave-infection-static-analysis-plugin --ansi --logger-github --ignore-msi-with-no-mutations --only-covered" 112 | ], 113 | "psalm": "psalm --show-info=true", 114 | "psalm:baseline": "psalm --set-baseline=psalm-baseline.xml", 115 | "psalm:ci": "psalm --output-format=github --shepherd --show-info=false --stats --threads=4", 116 | "refactor": "rector process --config=rector.php", 117 | "refactor:ci": "rector process --config=rector.php --dry-run --ansi", 118 | "stan": "phpstan analyse --memory-limit=2G", 119 | "stan:baseline": "phpstan analyse --generate-baseline --memory-limit=2G --allow-empty-baseline", 120 | "stan:ci": "phpstan analyse --memory-limit=2G --error-format=github", 121 | "test": [ 122 | "@putenv XDEBUG_MODE=coverage", 123 | "pest --color=always -v" 124 | ], 125 | "test:arch": [ 126 | "@putenv XDEBUG_MODE=coverage", 127 | "pest --color=always --configuration pest.xml.dist" 128 | ], 129 | "test:cc": [ 130 | "@putenv XDEBUG_MODE=coverage", 131 | "pest --coverage --coverage-clover=.build/phpunit/logs/clover.xml" 132 | ] 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /config/serializer.php: -------------------------------------------------------------------------------- 1 | , 16 | * encoderRegistrationStrategy: class-string, 17 | * metadataLoader: class-string|null, 18 | * } 19 | */ 20 | return [ 21 | /* 22 | * The 'default' key specifies the name (format) of the default serializer 23 | * that will be registered in SerializerManager. This can be overridden 24 | * by setting the SERIALIZER_DEFAULT_FORMAT environment variable. 25 | */ 26 | 'default' => env('SERIALIZER_DEFAULT_FORMAT', 'symfony-json'), 27 | 28 | /* 29 | * Specifies whether to enable debug mode for ProblemNormalizer. 30 | */ 31 | 'debug' => env('SERIALIZER_DEBUG_MODE', env('APP_DEBUG', false)), 32 | 33 | /* 34 | * Allows to specify additional, custom serializers that will be registered in SerializerManager. 35 | */ 36 | 'manager' => [ 37 | 'serializers' => [ 38 | 'json' => '', 39 | 'php' => '', 40 | ], 41 | ], 42 | 43 | /* 44 | * Allows you to specify the strategy class for registering your normalizers. 45 | * Default is 'WayOfDev\Serializer\DefaultNormalizerRegistrationStrategy'. 46 | */ 47 | 'normalizerRegistrationStrategy' => DefaultNormalizerRegistrationStrategy::class, 48 | 49 | /* 50 | * Allows you to register your custom encoders. 51 | * Default encoders are registered in src/DefaultEncoderRegistrationStrategy.php. 52 | * 53 | * Default encoders include: 54 | * JsonEncoder, 55 | * CsvEncoder, 56 | * XmlEncoder, 57 | * YamlEncoder. 58 | * 59 | * You can replace the default encoders with your custom ones by implementing 60 | * your own registration strategy. 61 | */ 62 | 'encoderRegistrationStrategy' => DefaultEncoderRegistrationStrategy::class, 63 | 64 | /* 65 | * Allows you to register your custom metadata loader. 66 | * 67 | * By default Symfony\Component\Serializer\Mapping\Loader\AttributeLoader is used. 68 | */ 69 | 'metadataLoader' => null, 70 | ]; 71 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended" 5 | ], 6 | "automerge": true, 7 | "platformAutomerge": true 8 | } 9 | -------------------------------------------------------------------------------- /src/Bridge/Laravel/Facades/Manager.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | declare(strict_types=1); 13 | 14 | namespace WayOfDev\Serializer\Bridge\Laravel\Http; 15 | 16 | interface HttpCode 17 | { 18 | public const HTTP_CONTINUE = 100; 19 | 20 | public const HTTP_SWITCHING_PROTOCOLS = 101; 21 | 22 | public const HTTP_PROCESSING = 102; 23 | 24 | public const HTTP_EARLY_HINTS = 103; 25 | 26 | public const HTTP_OK = 200; 27 | 28 | public const HTTP_CREATED = 201; 29 | 30 | public const HTTP_ACCEPTED = 202; 31 | 32 | public const HTTP_NON_AUTHORITATIVE_INFORMATION = 203; 33 | 34 | public const HTTP_NO_CONTENT = 204; 35 | 36 | public const HTTP_RESET_CONTENT = 205; 37 | 38 | public const HTTP_PARTIAL_CONTENT = 206; 39 | 40 | public const HTTP_MULTI_STATUS = 207; 41 | 42 | public const HTTP_ALREADY_REPORTED = 208; 43 | 44 | public const HTTP_IM_USED = 226; 45 | 46 | public const HTTP_MULTIPLE_CHOICES = 300; 47 | 48 | public const HTTP_MOVED_PERMANENTLY = 301; 49 | 50 | public const HTTP_FOUND = 302; 51 | 52 | public const HTTP_SEE_OTHER = 303; 53 | 54 | public const HTTP_NOT_MODIFIED = 304; 55 | 56 | public const HTTP_USE_PROXY = 305; 57 | 58 | public const HTTP_RESERVED = 306; 59 | 60 | public const HTTP_TEMPORARY_REDIRECT = 307; 61 | 62 | public const HTTP_PERMANENTLY_REDIRECT = 308; 63 | 64 | public const HTTP_BAD_REQUEST = 400; 65 | 66 | public const HTTP_UNAUTHORIZED = 401; 67 | 68 | public const HTTP_PAYMENT_REQUIRED = 402; 69 | 70 | public const HTTP_FORBIDDEN = 403; 71 | 72 | public const HTTP_NOT_FOUND = 404; 73 | 74 | public const HTTP_METHOD_NOT_ALLOWED = 405; 75 | 76 | public const HTTP_NOT_ACCEPTABLE = 406; 77 | 78 | public const HTTP_PROXY_AUTHENTICATION_REQUIRED = 407; 79 | 80 | public const HTTP_REQUEST_TIMEOUT = 408; 81 | 82 | public const HTTP_CONFLICT = 409; 83 | 84 | public const HTTP_GONE = 410; 85 | 86 | public const HTTP_LENGTH_REQUIRED = 411; 87 | 88 | public const HTTP_PRECONDITION_FAILED = 412; 89 | 90 | public const HTTP_REQUEST_ENTITY_TOO_LARGE = 413; 91 | 92 | public const HTTP_REQUEST_URI_TOO_LONG = 414; 93 | 94 | public const HTTP_UNSUPPORTED_MEDIA_TYPE = 415; 95 | 96 | public const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; 97 | 98 | public const HTTP_EXPECTATION_FAILED = 417; 99 | 100 | public const HTTP_I_AM_A_TEAPOT = 418; 101 | 102 | public const HTTP_MISDIRECTED_REQUEST = 421; 103 | 104 | public const HTTP_UNPROCESSABLE_ENTITY = 422; 105 | 106 | public const HTTP_LOCKED = 423; 107 | 108 | public const HTTP_FAILED_DEPENDENCY = 424; 109 | 110 | public const HTTP_TOO_EARLY = 425; 111 | 112 | public const HTTP_UPGRADE_REQUIRED = 426; 113 | 114 | public const HTTP_PRECONDITION_REQUIRED = 428; 115 | 116 | public const HTTP_TOO_MANY_REQUESTS = 429; 117 | 118 | public const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; 119 | 120 | public const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451; 121 | 122 | public const HTTP_INTERNAL_SERVER_ERROR = 500; 123 | 124 | public const HTTP_NOT_IMPLEMENTED = 501; 125 | 126 | public const HTTP_BAD_GATEWAY = 502; 127 | 128 | public const HTTP_SERVICE_UNAVAILABLE = 503; 129 | 130 | public const HTTP_GATEWAY_TIMEOUT = 504; 131 | 132 | public const HTTP_VERSION_NOT_SUPPORTED = 505; 133 | 134 | public const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; 135 | 136 | public const HTTP_INSUFFICIENT_STORAGE = 507; 137 | 138 | public const HTTP_LOOP_DETECTED = 508; 139 | 140 | public const HTTP_NOT_EXTENDED = 510; 141 | 142 | public const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; 143 | } 144 | -------------------------------------------------------------------------------- /src/Bridge/Laravel/Http/ResponseFactory.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | private array $context = []; 20 | 21 | private int $status = HttpCode::HTTP_OK; 22 | 23 | public function __construct(SerializerManager $serializer) 24 | { 25 | $this->serializer = $serializer->serializer('symfony-json'); 26 | } 27 | 28 | public function withStatusCode(int $code): self 29 | { 30 | $this->status = $code; 31 | 32 | return $this; 33 | } 34 | 35 | /** 36 | * @param array $context 37 | */ 38 | public function withContext(array $context): self 39 | { 40 | $this->context = $context; 41 | 42 | return $this; 43 | } 44 | 45 | public function create(object $response): IlluminateResponse 46 | { 47 | $content = $this->serializeResponse($response); 48 | 49 | return $this->respondWithJson($content, $this->status); 50 | } 51 | 52 | /** 53 | * @param array $response 54 | */ 55 | public function fromArray(array $response): IlluminateResponse 56 | { 57 | $content = $this->serializeResponse($response); 58 | 59 | return $this->respondWithJson($content, $this->status); 60 | } 61 | 62 | public function empty(): IlluminateResponse 63 | { 64 | return $this->respondWithJson('', HttpCode::HTTP_NO_CONTENT); 65 | } 66 | 67 | /** 68 | * @param array|object $response 69 | */ 70 | private function serializeResponse(array|object $response): string|Stringable 71 | { 72 | return $this->serializer->serialize( 73 | payload: $response, 74 | context: $this->context 75 | ); 76 | } 77 | 78 | private function respondWithJson(mixed $content, int $status): IlluminateResponse 79 | { 80 | return new IlluminateResponse( 81 | $content, 82 | $status, 83 | ['Content-Type' => 'application/json'] 84 | ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/Bridge/Laravel/Providers/SerializerServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->runningInConsole()) { 34 | $this->publishes([ 35 | __DIR__ . '/../../../../config/serializer.php' => config_path('serializer.php'), 36 | ], 'config'); 37 | } 38 | } 39 | 40 | public function register(): void 41 | { 42 | parent::register(); 43 | 44 | $this->mergeConfigFrom(__DIR__ . '/../../../../config/serializer.php', 'serializer'); 45 | 46 | $this->registerConfig(); 47 | $this->registerLoader(); 48 | $this->registerNormalizerRegistry(); 49 | $this->registerEncoderRegistry(); 50 | $this->registerSerializerRegistry(); 51 | $this->registerSerializerManager(); 52 | $this->registerSymfonySerializer(); 53 | } 54 | 55 | private function registerConfig(): void 56 | { 57 | $this->app->singleton(ConfigRepository::class, static function (Application $app) { 58 | /** @var Repository $config */ 59 | $config = $app->get(Repository::class); 60 | 61 | return Config::fromArray([ 62 | 'default' => $config->get('serializer.default'), 63 | 'debug' => $config->get('serializer.debug'), 64 | 'normalizerRegistrationStrategy' => $config->get('serializer.normalizerRegistrationStrategy'), 65 | 'encoderRegistrationStrategy' => $config->get('serializer.encoderRegistrationStrategy'), 66 | 'metadataLoader' => $config->get('serializer.metadataLoader'), 67 | ]); 68 | }); 69 | } 70 | 71 | private function registerLoader(): void 72 | { 73 | $this->app->singleton(LoaderInterface::class, static function (Application $app): LoaderInterface { 74 | /** @var Config $config */ 75 | $config = $app->make(ConfigRepository::class); 76 | 77 | return $config->metadataLoader(); 78 | }); 79 | } 80 | 81 | private function registerNormalizerRegistry(): void 82 | { 83 | $this->app->singleton(NormalizerRegistrationStrategy::class, static function (Application $app): NormalizerRegistrationStrategy { 84 | /** @var Config $config */ 85 | $config = $app->make(ConfigRepository::class); 86 | 87 | /** @var LoaderInterface $loader */ 88 | $loader = $app->get(LoaderInterface::class); 89 | 90 | $strategyFQCN = $config->normalizerRegistrationStrategy(); 91 | 92 | return $app->make($strategyFQCN, [ 93 | 'loader' => $loader, 94 | 'debugMode' => $config->debug(), 95 | ]); 96 | }); 97 | 98 | $this->app->singleton(NormalizerRegistryInterface::class, static function (Application $app): NormalizerRegistryInterface { 99 | /** @var NormalizerRegistrationStrategy $strategy */ 100 | $strategy = $app->get(NormalizerRegistrationStrategy::class); 101 | 102 | return new NormalizerRegistry($strategy); 103 | }); 104 | } 105 | 106 | private function registerEncoderRegistry(): void 107 | { 108 | $this->app->singleton(EncoderRegistrationStrategy::class, static function (Application $app): EncoderRegistrationStrategy { 109 | /** @var Config $config */ 110 | $config = $app->make(ConfigRepository::class); 111 | 112 | $strategyFQCN = $config->encoderRegistrationStrategy(); 113 | 114 | return $app->make($strategyFQCN); 115 | }); 116 | 117 | $this->app->singleton(EncoderRegistryInterface::class, static function (Application $app): EncoderRegistryInterface { 118 | /** @var EncoderRegistrationStrategy $strategy */ 119 | $strategy = $app->get(EncoderRegistrationStrategy::class); 120 | 121 | return new EncoderRegistry($strategy); 122 | }); 123 | } 124 | 125 | private function registerSerializerRegistry(): void 126 | { 127 | $this->app->singleton(SerializerRegistryInterface::class, static function (Application $app): SerializerRegistryInterface { 128 | /** @var SymfonySerializer $serializer */ 129 | $serializer = $app->make(SymfonySerializerInterface::class); 130 | 131 | $serializers = [ 132 | 'symfony-json' => new Serializer($serializer, 'json'), 133 | 'symfony-csv' => new Serializer($serializer, 'csv'), 134 | 'symfony-xml' => new Serializer($serializer, 'xml'), 135 | ]; 136 | 137 | if (class_exists(Dumper::class)) { 138 | $serializers['symfony-yaml'] = new Serializer($serializer, 'yaml'); 139 | } 140 | 141 | return new SerializerRegistry($serializers); 142 | }); 143 | } 144 | 145 | private function registerSymfonySerializer(): void 146 | { 147 | $this->app->singleton(SymfonySerializerInterface::class, static function (Application $app): SymfonySerializer { 148 | /** @var NormalizerRegistryInterface $normalizers */ 149 | $normalizers = $app->make(NormalizerRegistryInterface::class); 150 | 151 | /** @var EncoderRegistryInterface $encoders */ 152 | $encoders = $app->make(EncoderRegistryInterface::class); 153 | 154 | return new SymfonySerializer( 155 | $normalizers->all(), 156 | $encoders->all() 157 | ); 158 | }); 159 | 160 | $this->app->singleton(SymfonySerializer::class, SymfonySerializerInterface::class); 161 | $this->app->alias(SymfonySerializerInterface::class, 'symfony.serializer'); 162 | } 163 | 164 | private function registerSerializerManager(): void 165 | { 166 | $this->app->singleton(SerializerManager::class, static function (Application $app): SerializerManager { 167 | /** @var Config $config */ 168 | $config = $app->make(ConfigRepository::class); 169 | 170 | /** @var SerializerRegistry $serializers */ 171 | $serializers = $app->make(SerializerRegistryInterface::class); 172 | 173 | return new SerializerManager($serializers, $config->defaultSerializer()); 174 | }); 175 | 176 | $this->app->alias(SerializerManager::class, 'serializer.manager'); 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /src/Config.php: -------------------------------------------------------------------------------- 1 | |null */ 32 | private readonly ?string $normalizerRegistrationStrategy = null, 33 | /** @var class-string|null */ 34 | private readonly ?string $encoderRegistrationStrategy = null, 35 | /** @var class-string|null */ 36 | private readonly ?string $metadataLoader = null, 37 | ) { 38 | } 39 | 40 | /** 41 | * @param array{ 42 | * default: string, 43 | * debug: bool, 44 | * normalizerRegistrationStrategy: class-string, 45 | * encoderRegistrationStrategy: class-string, 46 | * metadataLoader: class-string|null, 47 | * } $config 48 | */ 49 | public static function fromArray(array $config): self 50 | { 51 | $missingAttributes = array_diff(self::REQUIRED_FIELDS, array_keys($config)); 52 | 53 | if ($missingAttributes !== []) { 54 | throw MissingRequiredAttributes::fromArray( 55 | implode(',', $missingAttributes) 56 | ); 57 | } 58 | 59 | return new self( 60 | $config['default'], 61 | $config['debug'], 62 | $config['normalizerRegistrationStrategy'], 63 | $config['encoderRegistrationStrategy'], 64 | $config['metadataLoader'] 65 | ); 66 | } 67 | 68 | public function defaultSerializer(): string 69 | { 70 | return $this->defaultSerializer; 71 | } 72 | 73 | public function debug(): bool 74 | { 75 | return $this->debug; 76 | } 77 | 78 | /** 79 | * @return class-string 80 | */ 81 | public function normalizerRegistrationStrategy(): string 82 | { 83 | if ($this->normalizerRegistrationStrategy === null) { 84 | return DefaultNormalizerRegistrationStrategy::class; 85 | } 86 | 87 | return $this->normalizerRegistrationStrategy; 88 | } 89 | 90 | /** 91 | * @return class-string 92 | */ 93 | public function encoderRegistrationStrategy(): string 94 | { 95 | if ($this->encoderRegistrationStrategy === null) { 96 | return DefaultEncoderRegistrationStrategy::class; 97 | } 98 | 99 | return $this->encoderRegistrationStrategy; 100 | } 101 | 102 | public function metadataLoader(): LoaderInterface 103 | { 104 | if ($this->metadataLoader !== null) { 105 | return new ($this->metadataLoader); 106 | } 107 | 108 | return new AttributeLoader(); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Contracts/ConfigRepository.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function normalizerRegistrationStrategy(): string; 15 | 16 | /** 17 | * @return class-string 18 | */ 19 | public function encoderRegistrationStrategy(): string; 20 | 21 | public function metadataLoader(): LoaderInterface; 22 | } 23 | -------------------------------------------------------------------------------- /src/Contracts/EncoderRegistrationStrategy.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | public function encoders(): iterable; 16 | } 17 | -------------------------------------------------------------------------------- /src/Contracts/EncoderRegistryInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | public function all(): array; 18 | 19 | /** 20 | * @param class-string $className 21 | */ 22 | public function has(string $className): bool; 23 | } 24 | -------------------------------------------------------------------------------- /src/Contracts/NormalizerRegistrationStrategy.php: -------------------------------------------------------------------------------- 1 | }> 14 | */ 15 | public function normalizers(): iterable; 16 | } 17 | -------------------------------------------------------------------------------- /src/Contracts/NormalizerRegistryInterface.php: -------------------------------------------------------------------------------- 1 | $priority 14 | */ 15 | public function register(NormalizerInterface|DenormalizerInterface $normalizer, int $priority = 0): void; 16 | 17 | /** 18 | * @return array 19 | */ 20 | public function all(): array; 21 | 22 | /** 23 | * @phpstan-param class-string $className 24 | */ 25 | public function has(string $className): bool; 26 | } 27 | -------------------------------------------------------------------------------- /src/Contracts/SerializerException.php: -------------------------------------------------------------------------------- 1 | $context Options normalizers/encoders have access to 15 | */ 16 | public function serialize(mixed $payload, ?string $format = null, ?array $context = []): string|Stringable; 17 | 18 | /** 19 | * Deserializes data into the given type. 20 | * 21 | * @param array $context 22 | */ 23 | public function deserialize( 24 | string|Stringable $payload, 25 | string|object|null $type = null, 26 | ?string $format = null, 27 | ?array $context = [], 28 | ): mixed; 29 | } 30 | -------------------------------------------------------------------------------- /src/Contracts/SerializerRegistryInterface.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | public function all(): array; 22 | 23 | public function has(string $name): bool; 24 | } 25 | -------------------------------------------------------------------------------- /src/DefaultEncoderRegistrationStrategy.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | public function encoders(): iterable 20 | { 21 | yield ['encoder' => new Encoder\JsonEncoder()]; 22 | yield ['encoder' => new Encoder\CsvEncoder()]; 23 | yield ['encoder' => new Encoder\XmlEncoder()]; 24 | 25 | if (class_exists(Dumper::class)) { 26 | yield ['encoder' => new Encoder\YamlEncoder()]; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/DefaultNormalizerRegistrationStrategy.php: -------------------------------------------------------------------------------- 1 | }> 32 | */ 33 | public function normalizers(): iterable 34 | { 35 | $factory = new ClassMetadataFactory($this->loader); 36 | 37 | yield ['normalizer' => new Normalizer\UnwrappingDenormalizer(), 'priority' => 50]; 38 | yield ['normalizer' => new Normalizer\ProblemNormalizer(debug: $this->debugMode), 'priority' => 100]; 39 | yield ['normalizer' => new Normalizer\UidNormalizer(), 'priority' => 150]; 40 | yield ['normalizer' => new Normalizer\JsonSerializableNormalizer(), 'priority' => 200]; 41 | yield ['normalizer' => new Normalizer\DateTimeNormalizer(), 'priority' => 250]; 42 | yield ['normalizer' => new Normalizer\ConstraintViolationListNormalizer(), 'priority' => 300]; 43 | yield ['normalizer' => new Normalizer\MimeMessageNormalizer(new Normalizer\PropertyNormalizer()), 'priority' => 350]; 44 | yield ['normalizer' => new Normalizer\DateTimeZoneNormalizer(), 'priority' => 400]; 45 | yield ['normalizer' => new Normalizer\DateIntervalNormalizer(), 'priority' => 450]; 46 | yield ['normalizer' => new Normalizer\FormErrorNormalizer(), 'priority' => 500]; 47 | yield ['normalizer' => new Normalizer\BackedEnumNormalizer(), 'priority' => 550]; 48 | yield ['normalizer' => new Normalizer\DataUriNormalizer(), 'priority' => 600]; 49 | yield ['normalizer' => new Normalizer\ArrayDenormalizer(), 'priority' => 650]; 50 | yield ['normalizer' => new Normalizer\ObjectNormalizer( 51 | classMetadataFactory: $factory, 52 | nameConverter: new MetadataAwareNameConverter($factory), 53 | propertyTypeExtractor: new PropertyInfoExtractor( 54 | typeExtractors: [new PhpDocExtractor(), new ReflectionExtractor()] 55 | ) 56 | ), 'priority' => 700]; 57 | 58 | if (interface_exists(UuidInterface::class)) { 59 | yield ['normalizer' => new RamseyUuidNormalizer(), 'priority' => 155]; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/EncoderRegistry.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | private array $encoders = []; 20 | 21 | public function __construct(EncoderRegistrationStrategy $strategy) 22 | { 23 | foreach ($strategy->encoders() as $encoder) { 24 | $this->register($encoder['encoder']); 25 | } 26 | } 27 | 28 | public function register(EncoderInterface|DecoderInterface $encoder): void 29 | { 30 | if (! $this->has($encoder::class)) { 31 | $this->encoders[$encoder::class] = $encoder; 32 | } 33 | } 34 | 35 | /** 36 | * @return list 37 | */ 38 | public function all(): array 39 | { 40 | return array_values($this->encoders); 41 | } 42 | 43 | /** 44 | * @phpstan-param class-string $className 45 | */ 46 | public function has(string $className): bool 47 | { 48 | return isset($this->encoders[$className]); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Exceptions/MissingRequiredAttributes.php: -------------------------------------------------------------------------------- 1 | serializer->serialize($payload, $this->format, $context); 26 | } 27 | 28 | public function deserialize(Stringable|string $payload, object|string|null $type = null, ?string $format = null, ?array $context = []): mixed 29 | { 30 | $context = $context ?? []; 31 | 32 | return $this->serializer->deserialize( 33 | (string) $payload, 34 | is_object($type) ? $type::class : $type, // @phpstan-ignore-line 35 | $this->format, 36 | $context 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Manager/SerializerManager.php: -------------------------------------------------------------------------------- 1 | defaultFormat; 21 | } 22 | 23 | public function serializer(?string $format = null): SerializerInterface 24 | { 25 | return $this->serializers->get($format ?? $this->defaultFormat); 26 | } 27 | 28 | /** 29 | * @param array $context 30 | */ 31 | public function serialize(mixed $payload, ?string $format = null, ?array $context = []): string|Stringable 32 | { 33 | $format = $format ?? $this->defaultFormat; 34 | 35 | return $this->serializer($format)->serialize($payload, $format, $context); 36 | } 37 | 38 | /** 39 | * Deserializes data into the given type. 40 | * 41 | * @param array $context 42 | */ 43 | public function deserialize( 44 | string|Stringable $payload, 45 | string|object|null $type = null, 46 | ?string $format = null, 47 | ?array $context = [], 48 | ): mixed { 49 | $format = $format ?? $this->defaultFormat; 50 | 51 | return $this->serializer($format)->deserialize($payload, $type, $format, $context); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Manager/SerializerRegistry.php: -------------------------------------------------------------------------------- 1 | $serializers 17 | */ 18 | public function __construct(private array $serializers = []) 19 | { 20 | foreach ($serializers as $name => $serializer) { 21 | $this->register($name, $serializer); 22 | } 23 | } 24 | 25 | public function register(string $name, SerializerInterface $serializer): void 26 | { 27 | $this->serializers[$name] = $serializer; 28 | } 29 | 30 | /** 31 | * @throws SerializerNotFound 32 | */ 33 | public function get(string $name): SerializerInterface 34 | { 35 | return $this->serializers[$name] ?? throw new SerializerNotFound($name); 36 | } 37 | 38 | /** 39 | * @return list 40 | */ 41 | public function all(): array 42 | { 43 | return array_values($this->serializers); 44 | } 45 | 46 | public function has(string $name): bool 47 | { 48 | return isset($this->serializers[$name]); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/NormalizerRegistry.php: -------------------------------------------------------------------------------- 1 | , normalizer: NormalizerInterface|DenormalizerInterface}> 19 | */ 20 | private array $normalizers = []; 21 | 22 | public function __construct(NormalizerRegistrationStrategy $strategy) 23 | { 24 | foreach ($strategy->normalizers() as $normalizer) { 25 | $this->register($normalizer['normalizer'], $normalizer['priority']); 26 | } 27 | } 28 | 29 | /** 30 | * @param int<0, max> $priority 31 | */ 32 | public function register(NormalizerInterface|DenormalizerInterface $normalizer, int $priority = 0): void 33 | { 34 | if (! $this->has($normalizer::class)) { 35 | $this->normalizers[$normalizer::class] = [ 36 | 'priority' => $priority, 37 | 'normalizer' => $normalizer, 38 | ]; 39 | } 40 | } 41 | 42 | /** 43 | * @return array 44 | */ 45 | public function all(): array 46 | { 47 | uasort( 48 | $this->normalizers, 49 | static fn (array $normalizer1, array $normalizer2) => $normalizer1['priority'] <=> $normalizer2['priority'] 50 | ); 51 | 52 | return array_column($this->normalizers, 'normalizer'); 53 | } 54 | 55 | /** 56 | * @phpstan-param class-string $className 57 | */ 58 | public function has(string $className): bool 59 | { 60 | return isset($this->normalizers[$className]); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Normalizers/RamseyUuidNormalizer.php: -------------------------------------------------------------------------------- 1 | $context 23 | */ 24 | #[Override] 25 | public function normalize(mixed $data, ?string $format = null, array $context = []): string 26 | { 27 | if (! $data instanceof UuidInterface) { 28 | throw new NotNormalizableValueException('Expected UuidInterface instance'); 29 | } 30 | 31 | return $data->toString(); 32 | } 33 | 34 | /** 35 | * @param array $context 36 | */ 37 | public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool 38 | { 39 | return $data instanceof UuidInterface; 40 | } 41 | 42 | /** 43 | * @param array $context 44 | */ 45 | public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): UuidInterface 46 | { 47 | try { 48 | return Uuid::fromString($data); 49 | } catch (InvalidArgumentException) { 50 | throw new NotNormalizableValueException( 51 | sprintf('The data is not a valid "%s" string representation.', $type) 52 | ); 53 | } 54 | } 55 | 56 | /** 57 | * @param array $context 58 | */ 59 | public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool 60 | { 61 | return is_string($data) && is_a($type, UuidInterface::class, true) && Uuid::isValid($data); 62 | } 63 | 64 | /** 65 | * @return array 66 | */ 67 | public function getSupportedTypes(?string $format): array 68 | { 69 | return [ 70 | UuidInterface::class => true, 71 | ]; 72 | } 73 | } 74 | --------------------------------------------------------------------------------