This package is abandoned and no longer maintained. The author suggests using the manialib/xml package instead.

Object-oriented PHP library for writing XML.

v0.1.1 2014-05-22 08:29 UTC

This package is auto-updated.

Last update: 2022-02-01 12:35:29 UTC


Latest Stable Version Latest Unstable Version Total Downloads Build

ManiaLib\XML is an object-oriented PHP library for writing XML.


Install via Composer:

	"require": {
        "maniaplanet/manialib-xml": "0.2.*@dev"


  • Simple and flexible object-oriented architecture
  • Configurable rendering drivers
  • Symfony\Component\EventDispatcher integration


  • You construct a tree of ManiaLib\XML\Node.
  • Setter methods return the element for chaining (eg. $node->setNodeName('foo')->setNodeValue('bar');.
  • ManiaLib\XML\Node::create() instanciates the object and returns it for easy chaining (eg. Node::create()->setNodeName('foo');).
  • If you're running PHP 5.4+ you can use class member access on instantiation instead eg. (new Node)->setNodeName('foo');.
  • See ManiaLib\XML\NodeInterface for reference.
  • You then pass the root Node to an instance of ManiaLib\XML\Rendering\Renderer.



use ManiaLib\XML\Node;
use ManiaLib\XML\Rendering\Renderer;

require_once '../vendor/autoload.php';

// Let's build a Node tree. Here is the root element.
$root = Node::create()
	->setAttribute('rootAttrivute', '1.0');

// This is one way to append child, ie. "append this element to its parent"
	->setAttribute('someAttribute', 'foo')
	->setAttribute('otherAttribute', 'bar')
	->setNodeValue('Hello world')

// This is another way, ie. "appends a child to this element"
$node = Node::create()->setNodeName('anotherOne');

// Let's render the tree
$renderer = new Renderer();
echo $renderer->getXML();

It will output:

<rootElement rootAttrivute="1.0">
    <someElement someAttribute="foo" otherAttribute="bar">
        Hello world

More in /examples directory


A simple suite tests .php files in the /examples directory against their associated .xml renders. To run the tests we recommand:


  • XMLComment
  • PhpDoc
  • Raw node value
  • Other unsupported Node features?