Download the PHP package lyte/xml without Composer

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

php-lyte-xml

Build Status Test Coverage Code Climate Issue Count

The base classes for XML work in php have a few little quirks that annoy me a lot, this is a simple collection of fixes for those annoyances.

Some of what I'm trying to put in is going to be purely experimental, so use at you're own risk :)

Examples

Nested CDATA in XMLWriter

There's a fairly well known method for working around the fact that XML doesn't actually let you nest a CDATA tag inside another one, but XMLWriter doesn't bother to apply this fix for you. Which is a problem if for instance you're transporting HTML fragments within another XML format.

With XMLWriter:

will result in:

which isn't valid XML!

Use Lyte\XML\XMLWriter instead and you'll get something that works the way you expect:

will result in:

Expanding to a DOMNode from XMLReader

With the native XMLReader if you call expand() you get back a DOMNode, which has its ownerDocument property set to null, which makes things like using a DOMXPath or saving it to an XML string snippet quite difficult.

E.g. with the native XMLReader:

results in:

... oops!

With Lyte\XML\XMLReader if you expand a node it creates the ownerDocument for you:

works this time:

Lazy XPaths

PHP has fairly relaible XPath support in the form of DOMXPath, but it's not directly attached to anything, breaking your nice OO context because now you either need to pass around two objects or continually reinstatiate your DOMXPath object.

Lyte\XML\DOMDocument will lazily create a DOMXPath object for use if you just ask for it, e.g. with the native DOMDocument:

with Lyte\XML\DOMDocument:

Contextified DOMNode XPath functions

Normally to run a XPath in a specific context you have to do a fair bit of set up, e.g.:

but Lyte\XML\DOMNode provides XPath functions directly that are already contextified:

There's also a Lyte\XML\DOMNode::xPathEvaluate() function that's synonymous with DOMXPath::evaluate() with the context already filled out.

Key/Value pair iterator

I seem to have to parse XML with key pairs a lot, e.g:

With Lyte\XML\DOMNodeList I've provided a toPairs() function to simplify this operation:

saveXML() anywhere

There's a commonish trick to get the XML just of a subtree of an XML DOM using ownerDocument like so:

with a Lyte\XML\DOMNode you can just ask it to save the XML directly:

Translate to UTF8 on the fly

Lyte\XML\XMLWriter

Simply state what the source encoding is and have it transcoded on the fly, e.g:

Produces:

Lyte\XML\DOMDocument::loadHTML()

Load HTML from an arbitrary character set:

Requirements

PHP 5.4+ or HHVM.

Caveats

Most of the classes I've created do not directly inherit from the XML ones, e.g. new Lyte\XML\DOMDocument() instanceof \DOMDocument is false. I've currently done this because to avoid duplicating memory all over the place and reserializing too much of the XML, I really need to use the decorator pattern, but even with PHP's magic methods I can't find a way to both inherit and decorate an object. I've even looked in to using the Reflection API to walk the upstream classes and selectively eval a new class in to existence, but ran in to problems with many of public properties getting updated at odd times by the base DOM classes.

The net result is a bunch of objects that walk like ducks, talk like ducks, but you might have trouble in weird corner cases convincing PHP that they're ducks, but still send me any bugs when you run in to issues.

If anyone can solve this, lodge an issue :)


All versions of xml with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
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 lyte/xml contains the following files

Loading the files please wait ....