Download the PHP package s9e/sweetdom without Composer

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

Overview

s9e\SweetDOM is a library that extends PHP's DOM extension to make DOM manipulation easier, with a particular emphasis on XSLT 1.0 templates. It adds syntactic sugar for the most common DOM operations, improves compatibility across PHP versions, and implements polyfills for some of the newer methods.

Code Coverage Scrutinizer Code Quality

Installation

API

s9e\SweetDOM\Document

The s9e\SweetDOM\Document class extends DOMDocument and provides quick access to DOMXPath's evaluate and query methods. The firstOf method evaluates the XPath query and returns the first node of the list, or null if the list is empty.

The s9e\SweetDOM\Document class has a $nodeCreator property that provides a set of methods to create elements with an emphasis on XSL elements commonly used in templates. See s9e\SweetDOM\NodeCreator for the full content.

s9e\SweetDOM\Element

The s9e\SweetDOM\Element class extends DOMElement and provides a set of magic methods to simultaneously create a node and insert it relative to the element. For each method from the s9e\SweetDOM\NodeCreator class, exist five corresponding methods on the s9e\SweetDOM\Element.

For instance, the createXslText method from s9e\SweetDOM\NodeCreator is declined into the afterXslText, appendXslText, beforeXslText, prependXslText, and replaceWithXslText methods in s9e\SweetDOM\Element. Each method creates a node, performs the DOM action, then returns the node. The following example illustrates where each xsl:text element is inserted relative to the span element from which they are created, then replaces the br element.

XPath methods are also accessible at the element level and use the element itself as context node:

Elements can be easily created and added relative to the context node via the following API:

Document fragments can be used to batch operations, or insert XML in a DOM.

Other extended nodes

The following DOM nodes are automatically extended and augmented with XPath methods as well as whichever magic methods are supported by the node type, usually via the DOMChildNode and DOMParentNode interfaces.

Backward and forward compatibility with older and future versions of PHP

In order to improve compatibility with older versions of PHP as well as future versions of PHP, this library uses a different set of classes to implement node types depending on the PHP version. The base classes are those listed above, in the s9e\SweetDOM namespace, and only those classes should be used when checking for class types.

Backward compatibility with older versions of PHP

Polyfills for the following methods are provided for PHP < 8.3:

On PHP older than 8.1.23, and on PHP versions from 8.2.0 to 8.2.9, the following methods are emulated:

Forward compatibility with future versions of PHP

The following methods have been modified to match PHP 8.3's behaviour with regards to disconnected nodes (nodes with no parent) and align with the DOM specification.


All versions of sweetdom with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-dom Version *
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 s9e/sweetdom contains the following files

Loading the files please wait ....