PHPackages                             horat1us/php-xml-convertible - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. horat1us/php-xml-convertible

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

horat1us/php-xml-convertible
============================

PHP Xml Convertible Object Trait

2.0.0(1y ago)11.9k1MITPHPPHP ^7.4 | ^8.0

Since May 1Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Horat1us/php-xml-convertible)[ Packagist](https://packagist.org/packages/horat1us/php-xml-convertible)[ RSS](/packages/horat1us-php-xml-convertible/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (15)Used By (0)

Simple trait that converts your object to DOMElement (XML)
==========================================================

[](#simple-trait-that-converts-your-object-to-domelement-xml)

[![Build Status](https://camo.githubusercontent.com/c01ad863b4ae204ec57f813c342d682ec1865e253b5083d509474a5e1f5dbd96/68747470733a2f2f7472617669732d63692e6f72672f486f7261743175732f7068702d786d6c2d636f6e7665727469626c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Horat1us/php-xml-convertible)[![Code Coverage](https://camo.githubusercontent.com/81e6aa1a188ead7c50aa2abece2b795b533c3f5221faadf49a1c9d1dae969d8d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f486f7261743175732f7068702d786d6c2d636f6e7665727469626c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Horat1us/php-xml-convertible/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/eee70a341f86c752617a3a81f7ab31daae6e200d3211824c5714dcd43205de23/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f486f7261743175732f7068702d786d6c2d636f6e7665727469626c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Horat1us/php-xml-convertible/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/dba8b8823bfff6402183efd1d52918710905a99c67d588eb33f6336e8b8f9c34/68747470733a2f2f706f7365722e707567782e6f72672f686f7261743175732f7068702d786d6c2d636f6e7665727469626c652f762f737461626c65)](https://packagist.org/packages/horat1us/php-xml-convertible)[![Latest Unstable Version](https://camo.githubusercontent.com/36ac60f9269214fc1fad2c395e410e4867943fcf60857c4df0963ea4cecfcade/68747470733a2f2f706f7365722e707567782e6f72672f686f7261743175732f7068702d786d6c2d636f6e7665727469626c652f762f756e737461626c65)](https://packagist.org/packages/horat1us/php-xml-convertible)[![License](https://camo.githubusercontent.com/f6fcd462b28db2a552dddd4666a129c368b8639e22d4e8240edab3502875ed40/68747470733a2f2f706f7365722e707567782e6f72672f686f7261743175732f7068702d786d6c2d636f6e7665727469626c652f6c6963656e7365)](https://packagist.org/packages/horat1us/php-xml-convertible)[![Total Downloads](https://camo.githubusercontent.com/2f56673d2d1813ad45ac4dd1da089b5e18c6489be05eea709ae775e2f5457197/68747470733a2f2f706f7365722e707567782e6f72672f686f7261743175732f7068702d786d6c2d636f6e7665727469626c652f646f776e6c6f616473)](https://packagist.org/packages/horat1us/php-xml-convertible)

1. [Trait](./src/XmlConvertible.php)
2. [Interface](./src/XmlConvertibleInterface.php)
3. [Examples](./examples/)

This trait automatically converts your object to XML representation (`DOMElement`). All your public properties (you can override method [getXmlProperties](./src/XmlConvertible.php#L69)) will be converted to attributes.

To declare children in your object you need to set [$xmlChildren](./src/XmlConvertible.php#L16) property.
To change element name you need to set [$xmlElementName](./src/XmlConvertible.php#L23) property *(short class name will be used by default)*

Install
-------

[](#install)

```
composer require horat1us/php-xml-convertible
```

Test
----

[](#test)

```
make test
```

Usage
-----

[](#usage)

You should just declare your class to implement `Horat1us\XmlConvertibleInterface` and use `Horat1us\\XmlConvertible` trait:

```
 Alexander
    [surname] => Letnikow
    [xmlChildren] => Array
        (
            [0] => Horat1us\XmlConvertibleObject Object
                (
                    [xmlChildren] => Array
                        (
                        )

                    [xmlElementName] => Head
                    [size] => big
                    [mind] => small
                )

        )

    [xmlElementName] => Person
)

```

**See tests to know more about all features.**

### License

[](#license)

This project is open-sourced software licensed under the [MIT license](./LICENSE)

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~249 days

Recently: every ~683 days

Total

12

Last Release

602d ago

Major Versions

1.4.0 → 2.0.02024-11-05

PHP version history (2 changes)1.0.0PHP &gt;=7.0

2.0.0PHP ^7.4 | ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2751367?v=4)[Horat1us](/maintainers/Horat1us)[@Horat1us](https://github.com/Horat1us)

---

Top Contributors

[![wearesho](https://avatars.githubusercontent.com/u/23651592?v=4)](https://github.com/wearesho "wearesho (40 commits)")[![Horat1us](https://avatars.githubusercontent.com/u/2751367?v=4)](https://github.com/Horat1us "Horat1us (4 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/horat1us-php-xml-convertible/health.svg)

```
[![Health](https://phpackages.com/badges/horat1us-php-xml-convertible/health.svg)](https://phpackages.com/packages/horat1us-php-xml-convertible)
```

###  Alternatives

[aloko/nova-persian-datepicker

Persian Datepicker for Laravel Nova.

203.6k](/packages/aloko-nova-persian-datepicker)[owenmelbz/laravel-robots-txt

Laravel 5.x helpers for a semi-automated robots.txt and meta tags

151.1k](/packages/owenmelbz-laravel-robots-txt)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
