 Yes, so welcome. I see that Larry did a better job of filling this room than I am Then again, maybe people are still pouring in over lunch Which is fine. Anyway, so I'll get started. So this is serialization with symphony and My name is Lucas Smith. I'm developer at Leib in Switzerland. I Did a few things in the PHP world One of the things was actually that I started the serializer component with Jordy It's kind of actually kind of funny because when I, you know Started on this talk or proposing this talk. I didn't quite remember if I actually did start it or not So I had to look at the commit history Yeah, I mean it was in the very early days of symphony that we started Feeling that we needed something like a serializer and I think it started I think it started initially outside of symphony and then was brought into symphony a little bit later on Yeah, and you can find me on Twitter with my with L Smith Now I have a slight confession to make so Some of you might know this guy and maybe as a quick show of hands who here was a Duplicon LA Okay, one person two person, okay I'm not sure did anybody attend this talk by So a serializer talk in LA So no, okay, that's great because I actually ended up stealing Hugo's slides for the most part and just updating them Mostly because I have a yeah two weeks ago I got married so I got I ended up being a little bit more busy than expected and also this day It's kind of crazy for me because I'm actually doing three talks And then I decided actually in the end that in the open source period kind of makes more sense that I improve upon What is already being created rather than creating the same slides again just with a different layout So these slides are updated from the version from LA There's two things that have happened in the serializer component since then a few typos that I fixed and obviously I'm going to put a slightly different slant on few of these slides obviously so Yeah, so without further ado, let's get going Yeah, so the today's topic is the serializer component and maybe first we need to figure out what serialization is and essentially it's taking you know a data structure usually in memory and then you know some object state or whatever and then You know bringing it to a different format that allows you to store and reconstruct this data usually in a you know string format and The different ways of you know or different formats that you can you know convert into or out of So for example HG messages, these are in the end just plain text messages So you can you know in in theory also just take you know an object and then serialize that to an Message and back In a way symphony kind of does that, you know We have a request and we have a response object and they get kind of transferred to string representations They don't use the serializer component though More classical ways of viewing serialization would be going to XML or back soap messages Jason Yammel CSV and so on so forth. I think in theory I don't I doubt that anybody has done it, but I guess you could also use the serializer component to generate PDFs and images But that would sort of be Kind of hard to deserialize again, but you could even do like text recognition them. I don't know Anyway, so the most common use cases of using serialization is you know You want to store some object state into a file or a database? REST API is probably even more the prime use case and this is how Drupal 8 uses the serializer component mostly You know generating soap in theory you could also use this to sort of distributed object instances the Java does that Where you know you can serialize an object to a string and then instantiate it back at it on a different server and continue processing there So Before we could dive into the symphony serializer component Let's look at some of the ways how we can actually do serialization just with out of the box features from PHP So there's you know the obvious choice is the serialized method so you basically throw in almost everything into the serialized method and You will then get back some string representation like this It's a little bit cryptic, but somewhat readable And then you can of course un-serialize that data And get back you know from that string representation to an actual variable with the different Types and so on so as you can see here You can you can have like nulls and Boolean values strings arrays and even objects as well Now there is something that is a little bit tricky With serialization is actually let me go back here. So as you can see here I don't have anything Or example of serializing a resource and that's because it's not possible with the PHP Serialized methods. So basically if you try to realize serialize something that contains the resource being it you know the resource itself or an array with resources or an object with resources you will get an error and With objects, however, you can work around this problem And there are these two magic methods that you can implement in your class underscore sleep and wake up And with these methods you can solve the problem of you know dealing with resources So let me give you a quick example here. So this would be some Database connection class you want to you know encapsulate PDO for example for some reason and you know in the constructor you might pass in a DSN a username and a password and then you have this connect method That you call at some point which actually creates a PDO instance and assigns it to a property and actually underneath PBO there is a resource and it You will run into problems if you just serialize that it's not going to come out properly connected to your database So the way to solve that is to implement these sleep and wake up methods So in the sleep method you basically specify which properties you want to include in the serialized Serialized format so in this case, which you're specifying the DSN user and password properties And and if you're not familiar with this curly bracket syntax This is short or an array syntax that was introduced in PHP 5.4 So this is essentially like when the return DSN user password This is just the same as saying return array parentheses and then these strings So that takes care about the case when we call serialized and then with wake up This method is called when you call unserialized on a string containing a reference to this class connection So what we do on the wake up We just basically call this connect method again that we saw in the previous slide So it'll you know take those the you know the values from the properties That I've already been set then from the unserialized method and then create the PDO instance again So we can thanks to these two methods here we can safely serialize the connection class and unserialize it again and And immediately have it connected So essentially you could do something like this, you know make an instance of that connection class run a query serialize The instance unserialized it again and then run another query Now there's also a new interface that was added. I'm trying to remember. I think it was pp5-4 serializable interface So this gives you another option. So instead of using these underscore underscore methods You can also implement the serializable interface And then you have this method serialized that you can overwrite and here you basically return an array Which can be you know a quite liberal data structure Of things that you want to serialize so you get more control in many ways, so you can do some data massaging like You know removing some additional data that you don't think belongs into the serialized serialized format And then in the unserialized method you basically get that data back serialized You can unserialize it again and then do additional things that you feel are important to do during the unserialization process You know these magic underscore underscore methods are sort of like an old style. I would say So this approach to me is definitely more object oriented And so therefore I would recommend it If you have a reason enough pgp version Now this format of course, this is a pgp custom format It has been you know fairly stable over many years But you know it's it's a pgp specific format and oftentimes you might want to exchange data with other systems when you do serialization so For that pgp also provides some ways to dealing with json for example Which is becoming more and more of a popular way to deal with serialization and data exchange between different systems Now there's two method to function story Jason encode and decode. They're basically the equivalent of serialized and unserialized and then there's also Fairly new addition also the Jason serializable Interface so the Jason serializable interface. It's kind of boils down to something very similar to what we saw with the serializable interface And you know you just get this Jason serialized method that you need to implement and then this will be used during encoding Okay, so that was very fast just going through the basics of how you can do Serialization with pgp out of the box without installing any additional components and so on so forth however Oftentimes when you deal with serialization you will end up in situations that are much more complex to deal with than what is possible out of the box and This is where the symphony serializer can help quite a bit actually and I said that I started the serializer, but when I originally started it was much more simple and it has grown quite a bit thanks to several other developers that have contributed to the component and I actually Haven't done anything to the component except for one. I think little thing for the composer Jason file a few days ago So many of the things that you're going to see here are not to my credit or Jordy's but actually other people in the symphony community So one of the things that we wanted to do with the serializer component was to Really enable people to deal with all sorts of formats So XML and Jason were the two that we focused in the beginning But from the very architect from the very beginning we architected things to enable people to be able to support other formats if they wish Even very custom formats or high-level formats like you could have serialized to your personal Style of Jason where you have a specific structure and Jason that you want and that would be very easy to achieve that And essentially the the architecture that we came up with was it was this so if you start off from from the object at the top and you want to Serialize that what we have is a process called normalization which basically brings you to sort of an area representation And then the area representation is passed on to what we call an encoder which then actually does the actual serialization And then the you know going back. It's the same essentially the same process in reverse You first decode into an array and then you Denormalize that into an object instance The there are methods that actually allow you to sort of start in the middle and then directly jump to an object or Directly go to a format, but the normal process is that you actually call These serialize and deserialize methods which basically do all of these two steps for you in one go So you don't have to call these separate methods So basically what you will be working with is an instance of the serializer And as I mentioned most of the time you'll just use the serialize and deserialize methods The serialize method basically gets some data. It can be whatever The format that you want to serialize into And then a context and we'll see later how that context can be very useful To sort of customize what should happen when a code happens and then deserialize is very similar You have a data type. This is useful If you you know to specify sort of what object you want to deserialize into Because you don't necessarily embed that into your serialized result The format again and then another the context again But if you wish to you can of course sort of skip some of the steps directly Just do a normalize or denormalize Endcode and decode and then with supports normalization and denormalization you can sort of validate Ahead of time if this will actually work or not and the same same thing for encoding There's the supports encoding and decoding methods So let's briefly see how that works. I assume that everybody is sort of familiar with namespace syntax In PHP 5.3. So you start off, you know with a few use statements Just to be able to use shorter class names in your code then You instantiate an array of so-called normalizers then an area of so-called encoders And you pass those in as the first and second parameter to the serializer And then and that's that's really key that basically depending on what sort of you pass in there Depends on how the serializer is going to work So if you for example skip adding that XML encoder, then you will not be able to Serialize into XML And if you add additional normalizers, then they can have different priority of different behaviors and produce different results for you But it essentially it's it's fairly easy to use then so once that serializer instance has been set up Then you can just call serialize pass in your data the format that you want and you just you know Get your serialized format back and then you can deserialize is quite easily here We can see in this case when we call deserialized. We're saying okay that data there is actually an instance of an acme user Object so please Use that class when you you know denormalize that data and then in this case We're saying this is actually, you know, what's realized adjacent so I'm serialized that Right, so here's a quick overview of the normalizers and denormalizers There's a small addition that happened since that talk in an LA the array denormalizer was added I think it's in 2.8. So I think it's not yet in the state release Most many cases you get away with just using that simple property normalizers the get set method normalizers And the object normalizers are actually quite similar the object normalizers a little bit more fancy can deal with Yeah, it uses the property axis component from symphony to figure out if there is a method defined to To get the the data from the object or if it should use a property And the get set method normalizer just has a little bit simpler logic and trying to figure out if there are methods to call rather than Just directly taking the property values The array denormalizers just a very handy thing if you have an array of Objects normalized And we'll later see actually the full implement or most of the implementation of it so we can dive into detail how it works Then encoders that are available out of the box is the json encoder and XML encoder So that's this is it what you have out of the box Then there's also the chain encoder and chain decoder because you might want to chain these so for example, as I mentioned earlier You know, you might have some high-level Syntax based on json that you want to Work into then you can have I don't know your your hell encoder Which extends the json encoder something like that could be possible, but Inheritance is always kind of a tricky thing So with the chain encoder you basically don't need to inherit You can basically just say okay. Here's the first encoder then the second encoder that you should use in this in these cases So a basic usage So let's look at you know, a very simple example. We have a movie class a bunch of private properties They can of course also be protected and You know you make an instance of that Object, you know assigning Different values to these properties through setters. Of course doesn't need to be setters But and then you can serialize and un-serialize that so that's pretty straightforward. We really haven't Done much more really that what we would get with the core features here Little word on the property serialization, so basically in this case we're we're just using that very simple property normalizer And so what we end up with is a json representation that really maps one to one to the property names we had in our class and same case for the XML serialization, so that's Basically depending on if you encode it to json or XML these were the two representations that you would get De-serialization is then also fairly easy again. That's pretty much straightforward what you essentially get with the core Jason encode in decode in this case then here the XML example You know we just get our representation back and this is essentially that print our statement on the previous slide This is what it would basically provide us with So exactly what we would want there's already one really cool feature in there Is that for the denormalization or de-serialization? Sorry one thing that it does it actually introspects the constructor and if it finds that the property names on your class match At least some of the or all of the constructor parameters Then it will actually call the constructor rather than directly setting out properties So if you follow that rule of naming your constructor parameters the same way as you name your Properties on your on your class you basically get an automatic call to your constructor Which could be useful to do certain things during setup like? Setting up some resource or things like that. So that's just very handy All right, so really this is this is more basics again We haven't really gained much compared to the core features So now next thing is actually seeing what more we can do So get our hazard is your method normalizers So this basically I'm not sure if you're all familiar with this term So if you have like a get something set something Has something or is something method these are called like get a hazard is or and so on so forth So basically you can leverage these if you use either the object normalizer or the get set method normalizers and so in this code example here, we basically added those two first lines up there basically adding those additional normalizers and What's important here to take away is that the order matters? so the normalizers are called in the order that they're put into this array and Remember there was this supports normalization methods on the serializer actually the normalizers have this method as well And so when the serializer goes through to determine if it Which normalizer to take it looks at the first one in the array sees if that one if the supports Normalization methods that's true then it will actually call that normalizer. So the order is very important to consider So in this case we have the object normalizer first and then the get set method normalizer second and then the property normalizer third Which I think will probably build on to it will probably most always use the object normalizer But I'm not entirely sure because the object normalizer will probably go up everything with this supports call anyway What is nice about this is that if let's say we have Extended our movie class to add some more methods like we have this get ID get title and then it has genre and is released method that The object normalizer will actually pick up these has genre and is released methods and actually add that to the serialized data It will also go through the get ID and the get title methods rather than directly accessing accessing the properties So in this case once you know we've added this basically we would get a serialization result where we have these added Peels here like genre and released and as you might notice here. It's not has genre or is released so this is sort of some special feature there in the object normalizer and then This XML serialization representation would look similar to that Now next is sometimes you don't want to serialize everything that you have in your object Like for example, you might have a user object. You might not want to serialize the password hash or whatever so you can do that by Calling the set ignored attributes method on the normalizer So basically if we say Set ignore attributes and we say ignore a stored key then basic means that That normalizer will ignore any property or you know get storage key or whatever method When it does the serialization So here we basically just have the same representation as before just with that one line omitted So now we you know, you're starting to see that there are some things that are you know more advanced compared to the the core serialization capabilities Now another thing that you might be concerned about is actually the naming inside your serialized format so For example, what you can do is you could use the camel case the snake case name converter And pass that in as a second parameter into your normalizer and then that will change the way that the The serialization then Happens to that you have in this case where we had release date that was previously camel case. This is now a snake case So that that's also quite convenient and in fact you can even customize that so you can create your own name converter So in this example, we want to create a name converter that actually prefixes the The serialization of each of these properties with the name of the class or sorry No with it with a prefix. I'm sorry. So just with the prefix So this is you know, you can create this on your own just implement that name converter interface which has been introduced in symphony 2.7 and You would get this result. So you call name or you make an instance of the prefix name converter you created pass in that prefix you want and then Set up your your normalizer and then if you would serialize that you basically would get everything prefix with movie underscore Another thing that we you might notice here is that in the XML representation We always have this response tag at the root and you might want to change that and this is where this context thing comes into play so Here we are using that third parameter on this context Parameter, which is just an array and we pass in XML root node name movie And as a result now we have a movie tag rather than a response tag And of course if you then you know you could you know have that context XML root name configured, but then choose to Serialize to JSON and then it will just be ignored Now deserializing into an existing object is also something that you might want so you might have like Some data that comes from the outside and some data that comes from your database And you want to enrich that Object that you got back from the database with some data that's coming from the outside So basically what you can do is you could you know you can have a movie instance in this case So here we see that this dollar movie one in case this case We're manually instantiating it, but it could come from you know any other system And then in the DC realize we could in the context specify object to populate and then instead of Creating a new instance it would take that instance and Put in whatever it finds in the serialized data and adds that to the given properties And you know whatever it doesn't override will then stay as is so So here in this example we see an XML where you know we have duration and release date And when we first created that movie instance we we didn't set these but Thanks to this Object to populate we would have both the data that we set up during the construction of the movie instance as well as what we had in the XML file So far so good So some even more Advanced things so one of the the challenging things to deal with serialization is You usually or in many cases end up having object graphs So you have you know one object that has a property In which you store another object and you know that graph can get really deep And So for this case there are some things that have been added to the serializer and these are These are things that in our initial implementation. We didn't even bother dealing with So it's really great that this has been added. So let's say we have in this movie class We have a property called genre which stores an instance of a genre class. We have Another property called directors, which is actually an array of director class instances and then we have a role Which is also an array of role instances and that role actually also has references to movies So we basically have a Cyclical dependency here. So we'll see how to deal with that. So first up Let's look at just the simple first case with the genre. We have a one-to-one Unidirectional relationship. So that's not so hard to deal with So an example here first we make an instance of genre We make an instance of movie assign that genre instance and then we serialize that to XML you know just for good measure we set it the root name to movie and Voila, this is what we would get in XML. So kind of what we would hope for right? We have the genre object embedded into the serialization of the movie Tag and then for Jason again what we would expect What's kind of nice here is that you might notice that the tag name genre here So here we don't we only need to set this for the root. We need to set what? What name to use here will you automatically use the property name? So there again just for the root we need to manual set it from then on it will already know what tag name to use All right, so next up. Let's look at the director case. So this is we basically dealing with an array of Object instances that are stored in the property. So one to many so we set up multiple directors and Assigned these To the movie class again here you get kind of what you would hope for kind of So here you have so the direct tours tag and Honestly what I would what wish for here rather is to be have a director tag. I guess but you know it depends on your taste But or you might want something that you know you have a directors tag and then you have multiple director tags within But this is what you get out of the box If you're doing if you're calling a serializer and this is what you would get with the json So that's out of the box already more or less what you would want With a you know directors key and then an area underneath Now next up it gets a little bit more tricky So we have a many to many relationship between the role because our role class looks like this We basically have a movie instance in there as well And so if we have a movie instance you know with You know that actually has several roles attached to it and the roles themselves also have the same movie reference You basically have a graph and that becomes a little bit more tricky to deal with because you know if you just keep serializing Then you know you come back and you basically are stuck in the loop So out of the box if you just call serialized now you would get an exception like this So a circular reference exception essentially But there's really some nice feature here You can set Circular reference handler on your normalizer What you and what you pass in here is actually a callable so in this case we're just using a closure and You just return an ID instead. So basically whenever it now encounters it or determines that this Is a circular dependency instead of throwing that exception. It's going to call that closure to figure out What representation to use instead? So now if we serialize that roles thing It will detect when it comes to the movie that this is a circular reference And then instead of going through the normal serialization process to try and serialize that it's just going to call our closure and get that ID so obviously This is a little bit simple in the sense that you might have like multiple You know scenarios for circular graphs and maybe it's not always to get ID method that you need to use there So maybe that function needs to be more complex like you actually need to check Is it an instant of that then call this method is an instant of that then call that method but Yeah, so basically it's not possible to deal with circular dependencies Now another thing that you might want to do and this is actually how Drupal 8 uses the symphony Serializer component extensively is with custom normalizers so So one thing that you know you might want to do is you might want to use the daytime instance Rather than just the string for the date in your object And so if you would serialize that then you know it works You know your serialized date will just look like this which is basically the serialized Representation of a daytime object, which is probably however not what you really want So what you could do is You could use A custom callback in your normalizer To deal with that specific case so again, we use the standard object normalizer And then we create a callback and this guy again This is the callable we're using a closure here And then you just set a callback and you define for which properties names you want to use the callback So in this case we do is release date birth date and death date And then instead of getting this ginormous representation, we get a much more compact representation Of a date which you know includes today the time and the time zone which should be sufficient to get our daytime object We stated when we deserialize So here's the Jason representation Yeah, and actually I kind of got confused so I just told you the callback normalizer This is not what Drupal 8 is using. This is what Drupal 8 is using custom normalizers So basically a custom normalizer you just need to implement the normalizable interface and Then either the normalized method if you just want to have a normalizer or as well the denormalizer If you want to have a denormalizer as well So to have a look here. So this is a custom Normalizer All right, sorry No, I'm getting confused again So we're still not where what Drupal 8 uses. So this is sorry backtracking So this is something so with this custom normalizer what you can do is you can actually attach some Logic about how to normalize that given object to that class itself So here we have the role and the role implements the normalizable interface And so with that normalizer interface instead of going through the normal normalizer when an account is such a An object instance is going to call the normalized method on that class So so basically this enables you especially when you're dealing with larger object graphs Sometimes it might not make sense to have like this ginormous chain of normalizers that you register to deal with all these special cases For all these different classes So with this normalizer interface You can add attach these this logic to the classes themselves So this is has the advantage that you don't have to register that many normalizers because as you might remember Otherwise we would have to iterate it over every normalizer to find the right one for the given class So this is sort of a way to optimize performance if you need to deal with lots of normalizers What is kind of ugly was it is that you're you end up sort of polluting your role object with something that I find is not responsibility of the role class itself to know how to serialize it how to serialize itself or how to normalize itself to an array So I think it's a sort of a little bit of a performance hack in my opinion But it can also be sort of nice in the way that you keep everything in one place Yeah, if you start end up having lots of normalizers, then this might be a better alternative There's also the serializer aware interface. So this is something if you create a custom normalizer you can basically Have it implement the serializer serializer aware interface, which basically means it's automatically going to get the serializer attached to it And this is this area denormalizer that I talked to talked about that is Coming in symphony 2.8 Basically what that that area denormalizer does is that when you call the the denormalized method There was a second parameter, which is called type and this type you usually specify a class name and With this area denormalizer what you can do is you can deal with areas of class instances so instead of just passing in the class name you actually specify a class name and then Brackets opening and closing brackets in the type that you pass in and as you see here in the supports denormalization Method what it does it checks is the end of that string Opening and closing brackets and do I support? denormalization of the type without those opening and closing brackets then it says this Airdy normalizer can denormalize this and then in the denormalizer method itself what it does it actually calls the denormalizer and Without those curly brackets so again the the point is that you can deal with an area of object instances and hint the type that You want to deserialize into Another really cool feature that was added to the serializer is serialization groups And this can be quite useful for example if you have different permissions and depending on permissions You want to show more or less? so let's say here we have the movie class again and We want to show the ID only to admins when we serialize But the title should be also viewable by other roles like publishers and users and so on so forth so these annotations also yaml configuration or xml configuration and in fact, I think you can also configure it via PHP You can configure these serialization groups then creating Or setting up your serializer comes a little bit more complicated So you need to set up the metadata loaders that you want to use you don't have to use all of them Of course, so if you just use annotations, you don't need the xml file or the yaml file loader and Yes, you basically configure your annotation loader Attach that to your class metadata factory and then pass that in as the first parameter to the object normalizer and You know, you just need to do that once of course in your code or when you set up your service And there you go. You now would have support for this group feature So if you call the serialized method now, you can add in your context You know the the group that you want to serialize to so users for example And then it will automatically apply the rules and in this case it would skip the ID property and would not serialize that and Therefore not expose that to the outside Now there's of course still development going on So one thing that is currently under discussion is in the denormalization to use type hitting So in many cases it actually is possible to sort of figure out What class to denormalize into When you're dealing with an object graph Because that's kind of like currently not really nicely possible So let's say we have an invoice class. This invoice class has a property with a customer And you know, we have the set customer method and it you know, it has a type in for the customer class and The idea here is that based on that sex cost set customer method And the type in that we have here is that the serializer could actually automatically figure out that in fact It needs to create an incident of the customer When it deserializes so this is currently being worked on As far as I know this will actually result in another component, right Fabian Are we doing the yeah, so this is going to be a new component? so Kevin he basically already created a component for dealing with Basically having a single API that can introspect and try to find such information Not only from type in but also from From PHP doc comments. It also supports PHP 7 return type hints and things like that And I think it also supports even hack slang. I don't know exactly I haven't looked at the code in detail, but with once we have that Component inside symphony. We can start using that in the serializer to vary More elegantly deal with deserialization of object graphs All right, so how do you use all of that in Drupal? So as I mentioned the serializer component is actually a core piece of Drupal 8 It's part of you know that the rest API said Dries was talking about this morning And so they're basically two modules. So the first one is the serialization module Which basically does the the core work of integrating the symphony serializer into Drupal and I'm not a Drupal expert by any means. I think the only time that I installed Drupal is kind of through platform at stage and spinning up a Drupal instance there And I tried to update these slides a little bit Based on like just seeing that the state has changed a little bit since the LA talk I think there's minor things that have changed since then essentially as a you know your core module You know with your your standard files The most interesting is interesting one and I'm actually going to show a little bit about that in the coming slides Is the the services that are being defined? Drupal 8 ships with lots of custom encoders and normalizers and They in turn use what is called entity resolvers. So this is a Drupal specific concept. That's not part of symphony itself And so here you see an overview of the normalizers So these are several normalizers available out of the box in Drupal 8 And as far as I know out of the box none of the symphony normalizers are being used in Drupal 8 right and now If you look at that serialization services.yaml This is not the entire content of the file. Essentially what you have here is You define a serial there's a serializer service here a normalizer and an encoder that's defined here What you might notice here is that you know these arguments to the serializer So this was this array of normalizers and arrays of encoders. This is empty here What what happens here is that Drupal actually uses something that that's called tags in That is supported by the dependency injection container. So here you see in that normalizer list service. It has a tag called name Normalizer and based on that Drupal will actually automatically realize that this is supposed to be a normalizer and Add that to the array that is being passed as the first argument up into that serializer service And the same thing happens with the encoder So here a JSON encoder instance is defined and then with the tag name encoder. It's going to be Created as an instance and pass into an array As a second parameter for the format JSON So you end up with You know lots of services that are being defined In most part the only one that you should be using is the one at the top serializer So that's the one that should be considered sort of public. The rest as far as I Sort of figure out from the Drupal 8 code is actually also public. So you can also get from the dependency injection container but I Wouldn't advise to use them because they might go away later in Drupal 8 or so on Because you really shouldn't need to use them because you can get everything that you need Sort of by just working with the methods available in the serializer Now there's a second module in there called the HAL module which sort of Expands on the basic JSON support to support HAL HAL is basically a Custom format on top of JSON actually it's also available for XML if I remember correctly Which basically enables you to build rest APIs with a little bit more assumptions that you get from the standard JSON Representation and so this module basically just adds a bunch of encoders and normalizers And then some additional services that are then through this tagging system also being attached to the serializer module serializer service Yeah, so here you just basically get some additional Services and here actually all of these should be considered private. I just screwed up on the slide there Now That basically concludes what I wanted to talk about for the serializer component I just wanted to briefly mention the JMS serializer library and this is actually a library that is actually the main reason why I stopped working on the serializer component itself because You want to Schmidt who created that did a really good job and very quickly supporting In handling circular graphs very elegantly and what he did there was also that instead of Where are you in the core of serializer what we have is basically you have these normalizers that are just Expected to be quite generic and how they deal with things or if you make them more specific you end up with this gigantic area What he did there was basically you have a lot of mapping files with where you specify how things should be normalized So it's a very different way of dealing with normalization. I thought at least initially it's more elegant It turns out that his approach is indeed very elegant. It's also very flexible And it's very powerful, but it comes at a big overhead. So basically especially for simpler cases You're going to have slower performance than what you could achieve easily with the serializer with less work configurations on so forth so I would say generally use the JMS serializer if you have very elaborate very deep object graphs and very much and in many Situations where you need to customize things And I would for simpler cases Use the symphony serializer There's one other thing to consider Which is important from a legal perspective the JMS serializer uses the Apache license Which is incompatible with the GPL license. So of course if you're creating your own code You can combine as you wish, but if you ship that code Then you're sort of in a legal gray area because so if you distribute code that is mixed between GPL and Apache license then Considering the fact that the both are incompatible. You're actually violating the licenses at least of the GPL So that's something to consider and that's also one of the reasons why the JMS serializer was never considered for core All right, so I'm already through with my slides and I assume there are probably some questions that I could answer There's a microphone over there if you have questions that we best But if not, I can just repeat it so we get it on the recording There's no movement everything was clear No questions any Comments or additions from some of the Drupal experts that can maybe say something relevant about Drupal that I cannot add I Guess then we're done a little bit early. I can I'll try to name drop something here So later on today. I'm doing a talk together with a co-worker of mine The talk is name is teal is the new orange. I'm not sure if everybody gets the reference to the TV show But the the topic this is actually sort of a soft Topic we're talking about self-managing organizations We talked a lot about basically how the company I work for leap is organized and how it's evolving and what we have Planned for the future so it's non-technical But to me this talk is really exciting I feel a lot of pressure because I feel very passionate about what we're talking there and So I hope I don't screw it up, but I would appreciate to have lots of people there because I think it's something That any organization can benefit from from benefit from or at least to have sort of any back of your head You know thinking of our organizations that are much more engaging much more rewarding to people and then I think Fundamentally also more productive So anyway, thank you very much for listening and have a great conference