# Laminas Serializer PHP objects \<\> Complex XML structs

**URL:** <https://discourse.laminas.dev/t/laminas-serializer-php-objects-complex-xml-structs/3918>\
**Category:** Components & MVC\
**Created:** [May 8, 2025, 12:55pm UTC](https://discourse.laminas.dev/t/laminas-serializer-php-objects-complex-xml-structs/3918 "2025-05-08T12:55:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ezkimo](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/ezkimo/32/781_2.png) [@ezkimo](https://discourse.laminas.dev/u/ezkimo)\
**Post date:** [May 8, 2025, 12:55pm UTC](https://discourse.laminas.dev/t/laminas-serializer-php-objects-complex-xml-structs/3918/1 "2025-05-08T12:55:04Z")

</div>

Is there a development based on laminas/serializer that can convert complex object structures into corresponding XML and back? Perhaps similar to what you might know from various C# or .NET implementations. Here is a small code example to illustrate this.

```auto
<?php

declare(strict_types=1);

namespace Marcel\Dto;

use Marcel\Serializer\Xml\Attribute;

final class SomeDto implements \Serializable
{
    public function __construct(
        #[Attribute\Attribute(name: 'XmlAttribute', type: 'SomeXmlType')]
        protected readonly string $attribute,

        #[Attribute\Element(name: 'XmlElement', type: 'SomeXmlType', namespace: '...']
        protected readonly string $element,
    ) {}

    public function serialize(): ?string
    {
        // some serializer serializes this object into proper xml
    }
}

```

Is something like that already available or do I have to code it for myself?

PS: I know, that there is some kind of outdated `XmlSerializer` class in PEAR. It feels kinda unconfy using PEAR extensions these days. I would gladly do without it.

Thanks for your advices in advance!
