PHPackages                             stanclik/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. stanclik/to-xml

ActiveLibary

stanclik/to-xml
===============

A simple library to generate xml files

03PHP

Since Feb 10Pushed 2y ago1 watchersCompare

[ Source](https://github.com/kubastanclik/toXml)[ Packagist](https://packagist.org/packages/stanclik/to-xml)[ RSS](/packages/stanclik-to-xml/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

toXML
=====

[](#toxml)

An easy-to-use library for generating XML files.

[![MIT License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://choosealicense.com/licenses/mit/)

Installation
------------

[](#installation)

Install usign composer

```
  composer require stanclik/toxml
```

Usage/Examples
--------------

[](#usageexamples)

```
require 'vendor/autoload.php';
use \Stanclik\ToXml\ToXml;
use \Stanclik\ToXml\Blocks;

$xml = new ToXml([]);

// set document header
$xml->setHeaders(Blocks::header(['version' => '1.0', 'encoding' => Blocks::UTF_8]));
// set root element
$xml->root('offers', ['param' => 'foo']);
$xml->add(
    Blocks::tag('item', [ // set item
        Blocks::tag('name', [Blocks::content('Some item')]),
        Blocks::tag('description', [Blocks::content('Some description')]),
        Blocks::tag('attributes', [ // set nested elements
            Blocks::tag('some-attribute', [], ['params' => 'foo']),
            Blocks::tag('some-attribute', [], ['params' => 'foo']),
            Blocks::tag('some-attribute', [], ['params' => 'foo']),
        ])
    ])
);
// call method to render xml;
$xml->render();

// print xml as a string;
header('Content-type: application/xml');
$xml->print();

// return xml as a string
$xml->get();
```

### Result:

[](#result)

```

             Some item ]]>

             Some description ]]>

```

Blocks
------

[](#blocks)

#### Header

[](#header)

```
Blocks::header([
    'version' => '1.0' // add header on start of the content
])
```

#### Tag

[](#tag)

```
Blocks::tag(
    'tag-name' // tag name ex:
    [
        // nested tags
    ],
    [
        'param' => 'foo' // params ex:
    ]
)
```

#### Content

[](#content)

```
Blocks::content(
    'Lorem Ipsum' // content inside the element,
    true|false // wrap the content in CDATA tags
)
```

#### Raw

[](#raw)

```
Blocks::raw(
    '' // just add raw tag
)
```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8622a3fb4545707ad8944b7f0100c9fb5ef5fde75b4901fc0677227c71f2d10a?d=identicon)[KubaStanclik](/maintainers/KubaStanclik)

---

Top Contributors

[![kubastanclik](https://avatars.githubusercontent.com/u/46523580?v=4)](https://github.com/kubastanclik "kubastanclik (3 commits)")

### Embed Badge

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

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

PHPackages © 2026

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