mark-gerarts / automapper-plus

An AutoMapper for PHP
MIT License
551 stars 30 forks source link

Added syntactic sugar for extending mappings #79

Open denisvanmorgan opened 3 years ago

denisvanmorgan commented 3 years ago

Hi, I was working recently with this package which I really like and kept struggling in situation where I need to define just one property of mapped class. I'm using unregistered mappings in project so I thought that I'm gonna define mapping just for that one property and keep the rest as they were mapped by "unregistered mapping". So I did that and realised I need to define mapping for each property when registering mapping (which in this case is very verbose) because unregistered mappings are registered on fly. But then I realised that I can get that already unregistered mapping by getMappingFor method and then register mapping for my class and copy that unregistered mapping to it and then finally define mapping for my property where I need to define it's unique format. This way I achieved that all properties are mapped and I'm overriding already mapped properties. This took me some time because it was not really obvious for the first time from code.

So I thought it would be nice to have it in form of syntactic sugar as a method. As you see I prepared this PR based on my experience and it's fully backward compatible without any issues because it uses well known methods of this projects.

Thank you for response

mark-gerarts commented 3 years ago

Thank you for the PR! I've read to the code and it's looking good, nice of you to include docs + tests as well. I'm going to play around around with this in the following days/weeks to make sure I really understand what's going on, and then I'll be merging this.

denisvanmorgan commented 3 years ago

Sure, no problem. Feel free to ping me in any case

fd6130 commented 2 years ago

Any good news for this PR?

maurei commented 9 months ago

Hello @mark-gerarts,

I'm considering introducing your php AutoMapper to our codebase at my employer. Trying to get a sense of the stability of this library. I noticed PR has been idle for a long term and the maintainer hasn't responded anymore.

I was hoping you could help me with understanding where this library is at?

Cheers

mark-gerarts commented 5 months ago

Hello @maurei, thank you for your interest. The current version of the library is being maintained, but at a very slow pace. This is due to two main reasons:

Concretely, this means that I focus on bugfixes, answering questions, and bumping dependencies (e.g. Symfony support of the bundle). Given enough interest I pick up bigger things, but only when I have the time and motivation to do so.

If you want a more up-to-date mapper, I suggest looking into https://github.com/jolicode/automapper. It emerged around the same time as this library (under Jane back then), and is being actively extended with new features (e.g. attributes). Documentation for the 8.x version is a bit sparse, take a look at the latest version instead. It is a mature implementation - at one point it was suggested as a Symfony component (discussion here).

On that note, also look into this RFC for more discussion on getting an object mapper into Symfony (it also continues the discussion on JoliCode's mapper).