PHPackages                             salernolabs/php-to-xml - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. salernolabs/php-to-xml

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

salernolabs/php-to-xml
======================

Simple class to convert PHP objects to XML, with tests.

v1.0.0(6y ago)01.2k↓50%5MITPHPPHP &gt;=7.2

Since Apr 14Pushed 6y ago1 watchersCompare

[ Source](https://github.com/salernolabs/php-to-xml)[ Packagist](https://packagist.org/packages/salernolabs/php-to-xml)[ Docs](http://www.salernolabs.com/)[ RSS](/packages/salernolabs-php-to-xml/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (6)Used By (5)

salernolabs/php-to-xml
======================

[](#salernolabsphp-to-xml)

[![Latest Stable Version](https://camo.githubusercontent.com/2dba4bb91ff9a0ce6227d70d6b90960c781ad07be9464b2ecf11bdecd998caa8/68747470733a2f2f706f7365722e707567782e6f72672f73616c65726e6f6c6162732f7068702d746f2d786d6c2f762f737461626c65)](https://packagist.org/packages/salernolabs/php-to-xml)[![License](https://camo.githubusercontent.com/9899165b8e8a044ea1559f503b2e68bd1d4949629161f7343fb99e84b7561614/68747470733a2f2f706f7365722e707567782e6f72672f73616c65726e6f6c6162732f7068702d746f2d786d6c2f6c6963656e7365)](https://packagist.org/packages/salernolabs/php-to-xml)[![Build Status](https://camo.githubusercontent.com/6485afd056d7f5c5931200c9e95f2e317a25445fbc9e37ed2f94246172361308/68747470733a2f2f7472617669732d63692e636f6d2f73616c65726e6f6c6162732f7068702d746f2d786d6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/salernolabs/php-to-xml)

Just a simple class that converts a PHP object to XML, with tests, and no SimpleXML requirement.

Yes, I'm fully aware of the existence of [SimpleXMLElement::asXML()](http://php.net/manual/en/simplexmlelement.asxml.php) and solutions that use it.

Usage
-----

[](#usage)

First include the package in your project via composer.

```
composer require salernolabs/php-to-xml

```

An example usage would be something like this:

```
$object = new \stdClass();
$object->hello = 'world';
$object->items = ['one', 'two', 'three'];
$object->samples = ['sample1'=>true, 'sample2'=>false, 'sample3'=>'I dunno!'];

$converter = new \SalernoLabs\PHPToXML\Convert();
$xml = $converter
    ->setObjectData($object)
    ->convert();

```

At this point, the value of `$xml` is expected to be a string with the following contents:

```

    world
    one
    two
    three

        1

        I dunno!

```

The converter is currently setup so multiple calls to convert() will return the last created data. Calls to setObjectData will clear the cache.

Limitations
-----------

[](#limitations)

I haven't added attribute or CDATA support in yet. It also doesn't collapse/remove empty nodes. Maybe later, pull requests welcome!

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~210 days

Total

5

Last Release

2480d ago

Major Versions

0.1.3 → v1.0.02019-08-03

PHP version history (3 changes)0.1.0PHP &gt;=7.0

0.1.2PHP &gt;=5.4

v1.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/155974?v=4)[Eric Salerno](/maintainers/ericsalerno)[@ericsalerno](https://github.com/ericsalerno)

---

Top Contributors

[![ericsalerno](https://avatars.githubusercontent.com/u/155974?v=4)](https://github.com/ericsalerno "ericsalerno (2 commits)")

---

Tags

convertsphpxmlphpxml

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/salernolabs-php-to-xml/health.svg)

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

###  Alternatives

[m1/vars

Vars is a simple to use and easily extendable configuration loader with in built loaders for ini, json, PHP, toml, XML and yaml/yml file types. It also comes with in built support for Silex and more frameworks to come soon.

69124.2k1](/packages/m1-vars)[goetas/xsd2php-runtime

Convert XSD (XML Schema) definitions into PHP classes

493.3k](/packages/goetas-xsd2php-runtime)[bupy7/xml-constructor

The array-like constructor of XML document structure.

1337.9k](/packages/bupy7-xml-constructor)

PHPackages © 2026

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