Download the PHP package fillup/array2xml without Composer

On this page you can find all versions of the php package fillup/array2xml. 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 array2xml

array2xml

array2xml is a simple library for converting arrays to XML

Why?

There are several libraries for converting arrays to XML, but they all require special syntax for annotating schema details for things like what to send array items as, attributes, and namespaces.

I was looking for a solution that would allow consumers of other libraries to provide an array without needing to know those xml schema details.

How it works

This library separates the array data from schema data so it is ideal for use in libraries where schema details are needed but you don't want to put that on users of your library. When instantiating the class you pass the data array as the first parameter and optionally provide a second array parameter with schema details.

This library supports serializing associative arrays, normal arrays, adding attributes, and namespaces.

The schema array is a simple format of an associative array where the key is the path/position in the array and the value is an array with schema details.

Associative arrays

Associative arrays are the easiest thing to serialize to XML because the format very naturally maps to .

Non-associative arrays

In PHP we represent normal arrays something like , but when serializing to XML this is a challenge because each element must be wrapped with a tag. This can be done by using the
element in the schema for a given position. See the example below where the contacts element in the array is an array of associative arrays. The scheme defines to send each as .

A2X also recognizes simple forms of plurals, so if the array data element has a name of and you do not specify what it's items should be sent as it will strip the trailing and send each as .

Attributes

If you need to use attributes in your xml, like you can do so by defining the attributes array in the schema for the position in the XML that needs attributes. The values of the array in the schema relate to what child elements should be serialized as attributes. This makes it very natural in the original array to just say:

and in the schema provide:

See the example below for how and have attributes.

Namespaces

If you need to use namespaces in your XML there are two places to define them. First you must provide the actual namespace definitions, that is the map from namespace prefix to URI. These are provided in the specal
element of the schema array. Second, for any given position in the schema array you can specify a
attribute with a single string value that should map to one of the prefixes defined in . See example below for how and are defined in and then used for positions and .

If you want to have all elements at and under a specific position to have the same namespace you can use the attribute in the schema. This will apply the given namespace to all elements below the given position.

List elements without a parent wrapping tag

If you need to generate a list of elements without a wrapping parent tag, the schema setting for
may be set to . By default it is considered if not present. This is useful in the following example where you have a list of but want them each listed as a element instead of as .

In that example (if formatted) would be:

Usage

In the above example, will contain the string:

A2X does not currently support pretty printing the xml as is displayed here, but I show it formatted for easier reading.

Contributing

Contributions are welcome as either issues or even better pull requests. If you like this library and use it, let me know, I'd love to know if others are benefiting from it as well. phillip dot shipley at gmail.

License

The MIT License (MIT)

Copyright (c) 2016 Phillip Shipley

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


All versions of array2xml with dependencies

PHP Build Version
Package Version
No informations.
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 fillup/array2xml contains the following files

Loading the files please wait ....