Download the PHP package magicsunday/xmlmapper without Composer

On this page you can find all versions of the php package magicsunday/xmlmapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package xmlmapper

XmlMapper: PHP Object to XML Mapping

Map strongly-typed PHP objects to XML using Symfony's PropertyInfo and TypeInfo components.

CI

PHPStan Max Level PHPUnit 12 | 13 Rector 2.0 PER-CS 2.0

Latest version


📌 Overview

XmlMapper is a PHP library that maps strongly-typed PHP objects (DTOs, value objects, entities) to XML using reflection and PHPDoc annotations. It leverages Symfony's PropertyInfo and TypeInfo components to derive each property's type and render a matching XML document.

Key Value
Package magicsunday/xmlmapper
PHP ^8.4
Main API MagicSunday\XmlEncoder
Output XML string (string); false only if serialization itself fails
Errors CircularReferenceException for a cyclic object graph, InvalidXmlValueException for a value XML cannot carry, UnmappableValueException for a value the encoder cannot map (false as the third constructor argument drops such a value silently instead), DOMException for an invalid element name

❓ What is this?

XmlMapper takes a PHP object implementing MagicSunday\XmlSerializable and renders it as XML, including nested objects, scalar and object collections, and custom types. Property values are routed to elements, attributes, raw text nodes or CDATA sections via a small set of annotations, and property names can be converted on the fly (e.g. snake_case to camelCase).

🎯 Why does this exist?

Serializing domain objects to XML usually means hand-writing DOMDocument/XMLWriter boilerplate that drifts from the underlying model. XmlMapper derives the XML structure from the object's typed properties and a few annotations, so the output follows the PHP model, with explicit hooks (attributes, CDATA, node values, custom type closures) where you need to deviate.

🚀 Usage

Quick start

Annotate the classes you want to serialize and let them implement XmlSerializable:

Build an encoder and map an instance:

The name converter is optional; without it the raw class and property names are used verbatim. For collections, annotate the property with the phpDocumentor collection type so the value type can be resolved:

Property markers

Each marker is applied as a native PHP attribute (shown above).

Marker Effect
XmlAttribute Render the value as an attribute of the surrounding element.
XmlNodeValue Render the value as the raw text content of the surrounding element.
XmlCDataSection Wrap the value in a <![CDATA[ … ]]> section (markup left intact).
XmlIgnore Leave the property out of the XML; it is not read at all.

Custom types

Register a closure to transform every value of a given class or builtin type (Money::class, bool, int, array, object, …) before it is written:

📚 Documentation

🛠️ Development

Prerequisites:

Install dependencies:

Run the mandatory quality gate:

ci:test includes:

The tool configurations import the shared rulesets of magicsunday/coding-standard, which also delivers the whole QA toolchain as a single dev dependency.

🤝 Contributing

Contributions are welcome. Please run the full composer ci:test quality gate before submitting a pull request, and keep changes covered by tests.


All versions of xmlmapper with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-xml Version *
ext-dom Version *
symfony/property-info Version ^7.3 || ^8.0
symfony/type-info Version ^7.3 || ^8.0
doctrine/inflector Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package magicsunday/xmlmapper contains the following files

Loading the files please wait ...