Are there any .Net automapper equivalent libraries but for php?
i.e. something that will copy all info from one class to another, for example user <-> userDTO.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Update: Yes there are! I wrote a little rudimentary library, which can be downloaded here: http://automapper.nylle.de
Original answer:
I haven’t heard of it, but I assume this to be rather unlikely, since PHP does not support return types for methods or functions. How can you possibly map the properties of two different classes, if you can only reflect their names, but not their types?
You could still write a little static helper class that simply gets two flat objects and copies all values from one property to the other class’ property with the same name using reflection, but this will only work, if you know what you do and the types are convertable (like scalar types string/int/bool).
Maybe you can put some more reliability into it by parsing the
phpdocpart (if available) to get a clue about the return type.