2017 © Pedro Peláez
 

library dom

The modern DOM API for PHP 7 projects.

image

phpgt/dom

The modern DOM API for PHP 7 projects.

  • Monday, July 30, 2018
  • by g105b
  • Repository
  • 6 Watchers
  • 28 Stars
  • 1,999 Installations
  • PHP
  • 15 Dependents
  • 0 Suggesters
  • 8 Forks
  • 16 Open issues
  • 49 Versions
  • 27 % Grown

The README.md

The modern DOM API for PHP 7 projects, (*1)

Modern DOM API.

Built on top of PHP's native DOMDocument, this project provides access to modern DOM APIs, as you would expect working with client-side code in the browser., (*2)

Performing DOM manipulation in your server-side code enhances the way dynamic pages can be built. Utilising a standardised object-oriented interface means the page can be ready-processed, benefiting browsers, webservers and content delivery networks., (*3)


Build status Code quality Code coverage Current version PHP.Gt/Dom documentation , (*4)

Example usage: Hello, you!

Important note: the example shown here is for illustrative purposes, but using the DOM to directly set data to elements' values tightly couples the logic to the view, which is considered bad practice. Please see the DomTemplate library for a more robust solution to binding data to the DOM., (*5)

Consider a page with a form, with an input element to enter your name. When the form is submitted, the page should greet you by your name., (*6)

This is a simple example of how source HTML files can be treated as templates. This can easily be applied to more advanced template pages to provide dynamic content, without requiring non-standard techniques such as {{curly braces}} for placeholders, or echo '<div class='easy-mistake'>' . $content['opa'] . '</div>' error-prone HTML construction from within PHP., (*7)

Source HTML (name.html)

<!doctype html>


Hello, you !

PHP used to inject your name (index.php)

<?php
use Gt\Dom\HTMLDocument;
use Gt\Dom\HTMLElement\HTMLSpanElement;
require "vendor/autoload.php";

$html = file_get_contents("name.html");
$document = new HTMLDocument($html);

if(isset($_GET["name"])) {
    $span = $document->querySelector(".name-output");
    $span->innerText = $_GET["name"];
}

echo $document;

Features at a glance

Known limitations / W3C spec compliance

This repository aims to be as accurate as possible to the DOM specification at https://dom.spec.whatwg.org/ - as of v4.0.0 all functionality is implemented with the following minor but unavoidable deviations from the standard:, (*8)

  • Elements' tagName property is uppercase.
  • To check the HTMLElement type, Element::getElementType() must be called - no subclasses of Element are available for usage with instanceof, for example.
  • The DOM specification defines functionality that is only possible to implement on the client-side. For example, HTMLInputElement::files returns a FileList that enumerates all files that are selected by the user through the browser's interface. This kind of functionality is impossible to implement server-side, but has been stubbed out for consistency with the specification. Attempting to use client-side functionality within this library throws a ClientSideOnlyFunctionalityException.

Data binding and page template features

This repository is intended to be as accurate to the DOM specification as possible. An extension to the repository is available at https://php.gt/domtemplate which adds page templating and data binding through custom elements and template attributes, introducing serverside functionality like that of WebComponents., (*9)

The Versions

30/07 2018

dev-master

9999999-dev

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

30/07 2018

dev-copyright

dev-copyright

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

24/07 2018

dev-dependabot/composer/symfony/css-selector-4.1.2

dev-dependabot/composer/symfony/css-selector-4.1.2

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/07 2018

dev-dependabot/composer/phpunit/phpunit-7.2.7

dev-dependabot/composer/phpunit/phpunit-7.2.7

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

31/05 2018

dev-dependabot/composer/symfony/css-selector-4.1.0

dev-dependabot/composer/symfony/css-selector-4.1.0

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

01/05 2018

dev-dependabot/composer/symfony/css-selector-4.0.9

dev-dependabot/composer/symfony/css-selector-4.0.9

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

29/04 2018

dev-pulls

dev-pulls

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

27/04 2018

dev-121-checkbox-test

dev-121-checkbox-test

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

23/04 2018

v1.0.3

1.0.3.0

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

23/04 2018

dev-contributors

dev-contributors

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/04 2018

v1.0.2

1.0.2.0

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

23/03 2018

dev-g105b-patch-1

dev-g105b-patch-1

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

23/03 2018

dev-contributing-1

dev-contributing-1

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

23/03 2018

dev-contributing

dev-contributing

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

06/03 2018

dev-dependabot/composer/symfony/css-selector-4.0.6

dev-dependabot/composer/symfony/css-selector-4.0.6

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

02/03 2018

dev-dependabot/composer/symfony/css-selector-4.0.5

dev-dependabot/composer/symfony/css-selector-4.0.5

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

27/02 2018

dev-dependabot/composer/phpunit/phpunit-6.5.7

dev-dependabot/composer/phpunit/phpunit-6.5.7

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

19/02 2018

dev-dependabot/composer/symfony/css-selector-4.0.4

dev-dependabot/composer/symfony/css-selector-4.0.4

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

20/01 2018

dev-102-nodelist

dev-102-nodelist

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

27/12 2017

dev-update-tests

dev-update-tests

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

12/12 2017

v1.0.1

1.0.1.0

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

01/11 2017

dev-91-doc-blocks

dev-91-doc-blocks

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

01/11 2017

dev-87-void-return-types

dev-87-void-return-types

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

21/08 2017

dev-documentation

dev-documentation

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/07 2017

dev-93-wrap-functions

dev-93-wrap-functions

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

30/05 2017

v1.0.0

1.0.0.0

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

30/05 2017

dev-27-emoji

dev-27-emoji

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

29/05 2017

dev-51-textcontent

dev-51-textcontent

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

19/05 2017

dev-43-tokenlist-case-sensitivity

dev-43-tokenlist-case-sensitivity

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

19/05 2017

v0.4.0

0.4.0.0

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

19/05 2017

dev-70-Node

dev-70-Node

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

18/05 2017

dev-66-HTMLDocument

dev-66-HTMLDocument

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

22/03 2017

dev-fragment

dev-fragment

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

18/11 2016

v0.3.2

0.3.2.0

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

22/10 2016

dev-Cleanup

dev-Cleanup

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

04/10 2016

dev-52-select

dev-52-select

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/07 2016

v0.3.1

0.3.1.0

The modern DOM API for PHP 7 projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

09/07 2016

v0.3.0

0.3.0.0

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

07/07 2016

v0.2.1

0.2.1.0

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

06/07 2016

v0.2.0

0.2.0.0

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/06 2016

v0.1.2

0.1.2.0

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

26/05 2016

v0.1.1

0.1.1.0

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

20/05 2016

v0.1.0

0.1.0.0

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

11/03 2016

dev-codacy

dev-codacy

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

24/02 2016

dev-16-ElementProperties

dev-16-ElementProperties

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

24/02 2016

dev-22-HTMLDocument-Attributes

dev-22-HTMLDocument-Attributes

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

24/02 2016

v0.0.3

0.0.3.0

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

03/02 2016

v0.0.2

0.0.2.0

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires

03/02 2016

v0.0.1

0.0.1.0

Enhancement to the PHP DOMDocument functionality.

  Sources   Download

MIT

The Requires

 

The Development Requires