2017 © Pedro Peláez
 

library manialib-xml

Object-oriented PHP library for writing XML.

image

maniaplanet/manialib-xml

Object-oriented PHP library for writing XML.

  • Monday, July 28, 2014
  • by magnetik
  • Repository
  • 7 Watchers
  • 0 Stars
  • 6,803 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

ManiaLib\XML

Latest Stable Version Latest Unstable Version Total Downloads Build, (*1)

ManiaLib\XML is an object-oriented PHP library for writing XML., (*2)

Installation

Install via Composer:, (*3)

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

Features

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

Architecture

  • 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.

Examples

<?php

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()
    ->setNodeName('rootElement')
    ->setAttribute('rootAttrivute', '1.0');

// This is one way to append child, ie. "append this element to its parent"
Node::create()
    ->setNodeName('someElement')
    ->setAttribute('someAttribute', 'foo')
    ->setAttribute('otherAttribute', 'bar')
    ->setNodeValue('Hello world')
    ->appendTo($root);

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

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

It will output:, (*4)

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

More in /examples directory, (*5)

Tests

A simple suite tests .php files in the /examples directory against their associated .xml renders. To run the tests we recommand: * PHPUnit system-wide installation via Composer * Run composer install * Run phpunit, (*6)

Todo

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

The Versions

28/07 2014

dev-master

9999999-dev https://github.com/maniaplanet/manialib-xml

Object-oriented PHP library for writing XML.

  Sources   Download

MIT

The Requires

 

The Development Requires

xml xmlwriter maniaplanet domdocument shootmania trackmania

23/05 2014

0.1.x-dev

0.1.9999999.9999999-dev https://github.com/maniaplanet/manialib-xml

Object-oriented PHP library for writing XML.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

xml

22/05 2014

v0.1.1

0.1.1.0 https://github.com/maniaplanet/manialib-xml

Object-oriented PHP library for writing XML.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

xml

21/05 2014

v0.1.0

0.1.0.0 https://github.com/maniaplanet/manialib-xml

Object-oriented PHP library for generating XML

  Sources   Download

MIT

The Requires

  • php >=5.3

 

xml