From 2d0aea7159f3e4a310255ffdc0fc399bc89a20d5 Mon Sep 17 00:00:00 2001 From: Baptiste Leduc Date: Thu, 4 Jan 2024 08:57:33 +0100 Subject: [PATCH] Make README simple & efficent --- README.md | 61 +++++++++++++------------------------------------------ 1 file changed, 14 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 26403f3..7c2af99 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,25 @@ # AutoMapper Bundle -The component ships a Bundle to allow a quick integration with Symfony. -To use it, you just have to add the main bundle class to your `config/bundles.php` file. +The AutoMapper Bundle is the Symfony bridge for [AutoMapper component](https://github.com/jolicode/automapper). + +## Quick Start 🚀 + +```shell +composer require jolicode/automapper-bundle ``` + +Then add the bundle to your bundles list in `config/bundles.php` +```php + ['all' => true], ]; ``` -Then configure the bundle to your needs, for example: -``` -automapper: - autoregister: true - mappings: - - source: AutoMapper\Bundle\Tests\Fixtures\User - target: AutoMapper\Bundle\Tests\Fixtures\UserDTO - pass: DummyApp\UserConfigurationPass -``` - -Possible properties: -- `normalizer` (default: `false`): A boolean which indicate if we inject the AutoMapperNormalizer; -- `cache_dir` (default: `%kernel.cache_dir%/automapper`): This settings allows you to customize the output directory for generated mappers; -- `mappings`: This option allows you to customize Mapper metadata, you have to specify `source` & `target` data types and related configuration using `pass` field. -This configuration should implements `AutoMapper\Bundle\Configuration\ConfigurationPassInterface`. -- `allow_readonly_target_to_populate` (default: `false`): Will throw an exception if you use a readonly class as target to populate if set to `false`. - -## Normalizer Bridge -A Normalizer Bridge is available, aiming to be 100% feature compatible with the ObjectNormalizer of the ``symfony/serializer`` component. The goal of this bridge **is not to replace the ObjectNormalizer** but rather providing a very fast alternative. - -As shown in the benchmark above, using this bridge leads up to more than 8x speed increase in normalization. - -## Future consideration -Things that could be done later: - -* symfony/form bridge for mapping request data to object -* symfony/validator integration: - -PHP 7.4 may give a problem to the symfony/validator component where typed properties can be problem, given a class like this: - -``` -class Foo { - /** @Assert\NotNull() */ - public int $foo; -} -``` - -An user may send a null value (in a form by example or JSON), and PHP will raise an error before the validation, since the validation occurs on the mapped object. - -This component can help resolving this case with the actual behavior: +You can read more about this library and how to use it on the [documentation](https://jolicode.github.io/automapper/#/symfony). -* Create a dummy class with the same properties as Foo but without type checking -* Mapping user data to this dummy class (using the automapper component) -* Validating this dummy class with the metadata from the Foo class -* Mapping the dummy object to the foo class (using the automapper component) +## Support -Feel free to challenge as much as possible. +For support, please create an issue on [GitHub tracker](https://github.com/jolicode/automapper-bundle/issues)