Download the PHP package pepve/dom-creator without Composer

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

DOM Creator for PHP

A limited but simple API for creating DOMDocumentS in PHP.

Short example:

Generates:

You first create a DomCreator instance with one of the factory functions. Then get and set properties on the object to create a DOM. New complex elements (the ones that contain other elements) are automatically created when you try to read them/set a property on them. This might look a little like setting properties on a regular object. The difference is that each action appends an element to the tree, instead of overwriting it. So the sequence of actions matters, contrary to setting stuff on an object.

When you try to get a property with the same name as the one you got previously, the previous node is returned. This is not always wanted, so this behaviour can be avoided with closeChild().

To write an attribute, prefix the property name with an underscore (this is set by DomCreator::ATTRIBUTE_SIGN). Elements and attributes that contain characters not allowed in a PHP identifier can be created by calling __get(..) and __set(..) yourself. Although you should think of using another API if this happens a lot.

Originally at: https://github.com/pepve/dom-creator-php

The API

DomCreator::create($nsUri, $nsPrefix, $root, $qualifyAttributes = false)

Create a new instance with a namespace and the given root element. The specified namespace URI and namespace prefix are used for all elements, but by default not for attributes. This can be changed by using true as the fourth argument.

DomCreator::createNoNamespace($root)

Create a new instance with the given root element, and without a namespace. You can optionally set a default namespace yourself with $domCreator->_xmlns = 'http://example.com/foo'.

DomCreator::createFragment($nsUri, $nsPrefix, $qualifyAttributes = false)

Create a new instance for use as a fragment. This allows functions to create some part of the DOM on their own. It can later be added to another tree like so: $domCreator->FragmentContents = $fragment. That action discards the fragment's root element, so this function allows you not to care about it.

DomCreator::createFragmentNoNamespace()

Create a new instance for use as a fragment, without a namespace.

__get($name)

Get a property. This creates and appends a new element with the name of the property and returns a new instance of this class to represent it. One exception: if the requested property has the same name as the last one requested and closeChild() has not been called, then return the same instance as on the last call (thus not creating a new element).

__set($name, $value)

Set a property. If the property name starts with an underscore (DomCreator::ATTRIBUTE_SIGN) this creates and appends a new attribute with the given name (attribute sign stripped) and value. Else a new element is created with the value as its contents. The value can be another instance of this class or a DOMNode, in which case all of their children are inserted in the new element.

closeChild()

Close the last child so nothing more will be appended to it.

getDocument()

Get the underlying DOMDocument of the tree, this is the same for each node in the tree.

getNode()

Get the underlying DOMElement of this node.

Some Examples

Example 1

Output:

Example 2

Output:

Automatically generated by readme.php


All versions of dom-creator 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 pepve/dom-creator contains the following files

Loading the files please wait ....