chillerlan/php-prototype-dom

Prototype.js like DOM traversal and manipulation. PHP 7.4+

3.0.1 2021-03-27 04:07 UTC

This package is auto-updated.

Last update: 2024-10-27 12:01:17 UTC


README

prototype.js like DOM traversal and manipulation for PHP 7.4+.

PHP Version Support version license Travis Coverage Scrunitizer Packagist downloads
CI phpDocs

Documentation

An API documentation created with phpDocumentor can be found at https://chillerlan.github.io/php-prototype-dom/ (WIP).

Requirements

Installation

requires composer

composer.json (note: replace dev-main with a version boundary)

{
	"require": {
		"php": "^7.4 || ^8.0",
		"chillerlan/php-prototype-dom": "dev-main"
	}
}

Profit!

Quickstart

use chillerlan\PrototypeDOM\Document;
use chillerlan\PrototypeDOM\Node\PrototypeHTMLElement;

$document = new Document(file_get_contents('https://www.php.net/supported-versions.php'));

$supportedVersions = $document->querySelectorAll('tr.stable > td:first-of-type > a')
	->map(fn(PrototypeHTMLElement $a):string => $a->value());

var_dump($supportedVersions); // -> ['7.4', '8.0']