chillerlan/php-prototype-dom

类似Prototype.js的DOM遍历和操作。PHP 7.4+

3.0.1 2021-03-27 04:07 UTC

This package is auto-updated.

Last update: 2024-08-27 11:41:29 UTC


README

类似prototype.js的PHP 7.4+ DOM遍历和操作。

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

文档

使用phpDocumentor创建的API文档可以在https://chillerlan.github.io/php-prototype-dom/(WIP)找到。

要求

  • PHP 7.4+
    • 需要DOMlibXML扩展

安装

需要composer

composer.json(注意:将dev-main替换为版本边界

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

盈利!

快速入门

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

$document = new Document(file_get_contents('https://php.ac.cn/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']