PHPackages                             originphp/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. originphp/dom

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

originphp/dom
=============

OriginPHP DOM

2.0.0(5y ago)17MITPHPPHP &gt;=7.3.0CI failing

Since Oct 11Pushed 5y ago1 watchersCompare

[ Source](https://github.com/originphp/dom)[ Packagist](https://packagist.org/packages/originphp/dom)[ Docs](https://www.originphp.com)[ RSS](/packages/originphp-dom/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

DOM
===

[](#dom)

[![license](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)[![build](https://github.com/originphp/dom/workflows/CI/badge.svg)](https://github.com/originphp/dom/actions)[![coverage](https://camo.githubusercontent.com/3f6103713d1c2ef85462fc39e62fd073b53512a1eec11dd097a0430ae6695540/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f726967696e7068702f646f6d2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/originphp/dom?branch=master)

The DOM utility extends the dom extension and provides javascript style query selectors (even when xpath fails).

The two functions functions that it adds to the PHP dom extension are `querySelector` and `querySelectorAll`. Unlike most other dom libraries, this does not use xpath to find elements. This is because during development, I found that translating my selectors from existing javascript code to xpath, i was not able to find the elements. When I tried downloading other libraries the same problem occurred. So I had to build from ground up so that the selector works the same as in javascript.

Currently it supports the following selectors:

- `.class` selects by class name
- `#id` selects by id
- `*` selects all elements
- `element` selects by tag name e.g. h1
- `element.class` selects a tag name with a class e.g. h1.heading will return all the h1 elements with the class heading
- `element,element` - Selects either elements e.g div,p will select all divs and paragraphs
- `element element` - e.g. div p will select all p in a div
- `[attribute=value]` - e.g. a\[target='\_blank'\] will select all links with target = \_blank
- `:first-child` - e.g. p:first-child will select the first child element from the p
- `:last-child` - e.g. p:last-child will select the last child element from the p
- `:nth-child(x)` = e.g. p:3 will select the third child.

At the moment it does not support the `~>+^|$` selectors.

Installation
------------

[](#installation)

To install this package

```
$ composer require originphp/dom

```

Usage
-----

[](#usage)

Example usage:

```
use Origin\Dom\Dom;
$dom = new Dom('1.0','UTF-8');
$dom->loadHtml($html); // this is a dom function
$element = $dom->querySelector('div.foo div.sub h1');
$paragraphs = $dom->querySelectorAll('div.p');
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~225 days

Total

3

Last Release

1957d ago

Major Versions

1.0.1 → 2.0.02021-01-04

PHP version history (3 changes)1.0.0PHP ^7.2.0

1.0.1PHP &gt;=7.2.0

2.0.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e8a821333d9c7b7bc2ad3d164d142f65cd3912dea78033d31f76b0f19ba8a0c?d=identicon)[originphp](/maintainers/originphp)

---

Top Contributors

[![jamielsharief](https://avatars.githubusercontent.com/u/20553479?v=4)](https://github.com/jamielsharief "jamielsharief (12 commits)")

---

Tags

originPHP

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/originphp-dom/health.svg)

```
[![Health](https://phpackages.com/badges/originphp-dom/health.svg)](https://phpackages.com/packages/originphp-dom)
```

###  Alternatives

[mrgoon/aliyun-sms

阿里云短信服务php调用代码

8292.9k](/packages/mrgoon-aliyun-sms)[carrooi/nette-menu

Menu control for Nette framework

2950.0k1](/packages/carrooi-nette-menu)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
