title: Passing objects between microservices
body: <p>I am experimenting with moving some parts of a monolith to external services. I like the idea so far and it seems a lot cleaner to encapsulate all related functionality inside one application. The different applications use RabbitMQ to communicate. </p>
  
  <p>I have a user object in one service. If I want to use this exact same class in the service I can easily serialize it and send the serialized object in the message body. But since both the sender and receiver need to contain the user class I would have to share a library containing some representation of the user object (although to me it seems strange to put the real user object in the library since it's core to the main application). I guess I could also just pass an array with a <code>user</code> key and defined key-values.</p>
  
  <p>I'm also thinking that if I someday create a service in something other than PHP then it won't be able to unserialize the user object and thus will have no access to the data in the message.</p>
  
  <p>So basically I like the idea of passing entities between services and being able to user them as objects in the receiving end, but I'm not sure if this is the right approach.</p>
  
  <p>My question is what would the best way to pass objects between these services be?</p>