2017 © Pedro Peláez
 

library xml-constructor

The XML of document structure constructor.

image

bupy7/xml-constructor

The XML of document structure constructor.

  • Wednesday, December 6, 2017
  • by bupy7
  • Repository
  • 3 Watchers
  • 8 Stars
  • 380 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 7 Versions
  • 6 % Grown

The README.md

xml-constructor

Stable Version Build status Coverage Status Total Downloads License, (*1)

The array-like constructor of XML document structure., (*2)

Supporting PHP from 5.6 up to newest., (*3)

Install

Add the following to require section of your composer.json:, (*4)

"bupy7/xml-constructor": "*"

Then do composer install;, (*5)

or execute the command:, (*6)

$ composer require bupy7/xml-constructor

Usage

Input:, (*7)

$xml = new XmlConstructor();
$in = [
    [
        'tag' => 'root',
        'elements' => [
            [
                'tag' => 'tag1',
                'attributes' => [
                    'attr1' => 'val1',
                    'attr2' => 'val2',
                ],
            ],
            [
                'tag' => 'tag2',
                'content' => 'content2',
            ],
            [
                'tag' => 'tag3',
                'elements' => [
                    [
                        'tag' => 'tag4',
                        'content' => 'content4',
                    ],
                ],
            ],
            [
                'tag' => 'tag4',
                'content' => '<b>content4</b>',
                'cdata' => true, // by default - false, see https://en.wikipedia.org/wiki/CDATA
            ],
        ],
    ],
];
echo $xml->fromArray($in)->toOutput();

Output:, (*8)

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <tag1 attr1="val1" attr2="val2"/>
    <tag2>content2</tag2>
    <tag3>
        <tag4>content4</tag4>
    </tag3>
    <tag4><![CDATA[<b>content4</b>]]></tag4>
</root>

Configuration:, (*9)

$xml = new XmlConstructor([
    // Indent each line in the XML document. 4 space by default.
    'indentString' => '    ',
    /* Header document tag. "<?xml version="1.0" encoding="UTF-8"?>" by default. */
    'startDocument' => [
        // version
        '1.0',
        // encoding
        'UTF-8',
    ],
]);

You can set up indentString and/or startDocument as null to disable them., (*10)

Testing

Run tests:, (*11)

$ ./vendor/bin/phpunit --no-coverage

Run tests with coverage:, (*12)

$ XDEBUG_MODE=coverage ./vendor/bin/phpunit

HTML coverage path: build/coverage/index.html, (*13)

Code style

To fix code style, run:, (*14)

~/.composer/vendor/bin/php-cs-fixer fix --verbose

You have to install PHP CS Fixer at first, if you don't use build-in Docker image:, (*15)

composer global require friendsofphp/php-cs-fixer

License

xml-constructor is released under the BSD-3-Clause License. See the bundled LICENSE.md for details., (*16)

The Versions

06/12 2017

dev-master

9999999-dev

The XML of document structure constructor.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4
  • ext-libxml *

 

The Development Requires

by Vaseelie Belosloodcev

php xml library xml constructor xml writter xml maker

06/12 2017

1.2.4

1.2.4.0

The XML of document structure constructor.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4
  • ext-libxml *

 

The Development Requires

by Vaseelie Belosloodcev

php xml library xml constructor xml writter xml maker

18/09 2017

1.2.2

1.2.2.0

The XML of document structure constructor.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4
  • ext-libxml *

 

The Development Requires

by Vaseelie Belosloodcev

php xml library xml constructor xml writter xml maker

27/01 2016

1.2.1

1.2.1.0

The XML of document structure constructor.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4
  • ext-libxml *

 

The Development Requires

php xml library xml constructor xml writter

21/12 2015

1.2.0

1.2.0.0

The XML of document structure constructor.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4
  • ext-libxml *

 

php xml library xml constructor xml writter

27/08 2015

1.1.0

1.1.0.0

The XML of document structure constructor.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4

 

php xml library xml constructor xml writter

23/07 2015

1.0.0

1.0.0.0

The XML of document structure constructor.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4

 

php xml library xml constructor xml writter