PHPackages                             magento/dom - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. magento/dom

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

magento/dom
===========

The modern DOM API for PHP 7 projects.

v2.1.7(6y ago)21.0M↓23.3%1MITPHPPHP &gt;=7.1

Since Feb 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/magento/Dom)[ Packagist](https://packagist.org/packages/magento/dom)[ RSS](/packages/magento-dom/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (47)Used By (0)

[![The modern DOM API for PHP 7 projects](logo.png)](logo.png)

Modern DOM API.
===============

[](#modern-dom-api)

Built on top of PHP's native [DOMDocument](http://php.net/manual/en/book.dom.php), this project provides access to modern DOM APIs, as you would expect working with client-side code in the browser.

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, benefitting browsers, webservers and content delivery networks.

---

[ ![Build status](https://camo.githubusercontent.com/acd3b433af5a7bdfafc66e093771f715091b9bb5507fc94747d22e367b91b99f/68747470733a2f2f62616467652e7374617475732e7068702e67742f646f6d2d6275696c642e737667)](https://circleci.com/gh/PhpGt/Dom)[ ![Code quality](https://camo.githubusercontent.com/98f19628a9533af724fde5bcf95a43cb3f1b2645beac5c368adaac73d5441df3/68747470733a2f2f62616467652e7374617475732e7068702e67742f646f6d2d7175616c6974792e737667)](https://scrutinizer-ci.com/g/PhpGt/Dom)[ ![Code coverage](https://camo.githubusercontent.com/a6e33699401ff359416e9dd7b5a6bd4081b065c76b45c419b3bf3c0479d775d1/68747470733a2f2f62616467652e7374617475732e7068702e67742f646f6d2d636f7665726167652e737667)](https://scrutinizer-ci.com/g/PhpGt/Dom)[ ![Current version](https://camo.githubusercontent.com/e7869dcc279dd8f67154f6f90ff34f5be0d46dea814ff8a34f243d17d0e6386d/68747470733a2f2f62616467652e7374617475732e7068702e67742f646f6d2d76657273696f6e2e737667)](https://packagist.org/packages/PhpGt/Dom)[ ![PHP.Gt/Dom documentation](https://camo.githubusercontent.com/08fef26351638a63f0357d4382c10c68ca33b4b8fa191285fcf98ca359f5d077/68747470733a2f2f62616467652e7374617475732e7068702e67742f646f6d2d646f63732e737667)](http://www.php.gt/dom)Example usage: Hello, you!
--------------------------

[](#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](https://php.gt/domtemplate) library for a more robust solution to binding data to the DOM.

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.

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 '' . $content['opa'] . ''` horrible HTML construction from within PHP.

### Source HTML (`name.html`)

[](#source-html-namehtml)

```

	Hello, you !

	Submit

```

### PHP used to inject your name (`index.php`)

[](#php-used-to-inject-your-name-indexphp)

```
