gravitypdf/querypath
PHP library for HTML(5)/XML querying (CSS 4 or XPath) and processing (like jQuery) with PHP 7.0 to 8.5 support
4.2.0
1.7M downloads/mo
#2313 most downloaded on Packagist
GravityPDF/querypath
What this package is like to depend on
Last release 5 months ago
17 Mar 2026
Release timing varies
gaps range from 3 months to 3.7 years
Nearly every release is documented
notes for 19 of 20 stable releases
Nothing withdrawn
no release was ever pulled
15 years old
23 releases · first in 2012
1 release in the last 12 months
see the full history below
Release timeline
23 releases · Feb 2012 to Mar 2026Releases
latest 23-
4.2.017 Mar 2026Release notes
Open source → -
4.1.004 Feb 2025Release notes
Open source →What's Changed
- Mark as PHP 8.4 compatible by @jakejackson1 in #59
- Additional fix for :nth-child(n+B) by @super-dm3 in #60
- Fix error when getting parents() for HTML elements by @super-dm3 in #61
Full Changelog: 4.0.1...4.1.0
Release notes
Open source →- Update composer.json to mark library as PHP 8.4 compatible
- Use
\QueryPath\CSS\DOMTraverser\Util::parseAnB()in\QueryPath\CSS\QueryPathEventHandlerclass to parse the:nth-child(an+b)syntax - Deprecate protected method
\QueryPath\CSS\QueryPathEventHandler::parseAnB()in favor of public static method\QueryPath\CSS\DOMTraverser\Util::parseAnB()
-
4.0.107 Nov 2024Release notes
Open source →What's Changed
- Only define global functions qp(), htmlqp(), and html5qp() if they haven't already been defined by @jakejackson1 in #53
- Fix for :nth-child(n+B) to select B-th and all following elements by @super-dm3 in #56
New Contributors
- @super-dm3 made their first contribution in #56
Full Changelog: 4.0.0...4.0.1
Release notes
Open source →- Only define global functions qp(), htmlqp(), and html5qp() if they haven't been defined already.
- Fix for :nth-child(n+B) to select B-th and all following elements
- Fix for :nth-child(-n+B) to select first B elements
- Update PHPUnit Test Suite to use @dataProvider in testPseudoClassNthChild() to reduce code repetition
- Fix error when getting parents() for HTML elements
-
4.0.012 Aug 2024Release notes
Open source →What's Changed
- Reverse logic of html5() Method by @jakejackson1 in #43
- Fix return value of wrapAll() when count() is 0 by @jakejackson1 in #44
Full Changelog: 3.2.3...4.0.0
Release notes
Open source →- Reverse logic in DomQuery::html5() so that DomQuery::html5() returns the content of the current match, and DomQuery::html5('') replaces the content of the current matches. This matches the existing logic used in DomQuery::html().
- Return DOMQuery object if QueryMutators::wrapAll() has no matches (instead of null). This aligns the method with the Docblock return type.
-
3.2.301 Dec 2023Release notes
Open source →- Add PHP 8.3 Support
- Fix type mismatch for classes that implement the "Query" interface
-
3.2.211 Dec 2022Release notes
Open source →What's Changed
- PHP 8.2 Support by @jakejackson1 in #26
- Improve type hinting on primary functions by @jakejackson1 in #37
Full Changelog: 3.2.1...3.2.2
-
3.2.108 Dec 2022Release notes
Open source →What's Changed
- Resolve PHP8.1 Deprecation Notice by @jakejackson1 in #32
Full Changelog: 3.2.0...3.2.1
-
3.2.007 Dec 2022Release notes
Open source →What's Changed
The library was forked from https://github.com/arthurkushman/querypath, which was forked from https://github.com/technosophos/querypath.
Bug Fixes
- Fixes a number of type-related errors on PHP 8.1
Documentation and Maintenance
- Added GitHub Issue and Pull Request template
- Added Contributor Guidelines
- Updated README. Includes better getting started examples, info about the fork, and contributing
- Added GitHub Action to auto-lock closed issues/PRs
- Added CHANGELOG.md
- Added SECURITY.md
- Added FUNDING.md
- Removed API file and merged contents with new CHANGELOG.md file
- Renamed COPYING-MIT.txt to LICENSE.txt
- Updated composer.json
- Changed PHP requirements from
>=7.1to^7.1 || ~8.0.0 || ~8.1.0so developers are explicitly aware which PHP versions are supported by the library - Applied PSR-2 rules (+ tabs instead of spaces) to entire codebase
- Renamed
masterbranch tomain
Full Changes: 3.1.4...3.2.0
Release notes
Open source →- Fixes a number of type-related errors on PHP 8.1
- Update PHPUnit Test Suite to pass from PHP7.1 to 8.1
- Add GitHub Actions to run PHPUnit for all PRs
- Removes composer.lock file to ensure the correct PHPUnit is installed in GitHub Actions. Since this is a library this is generally the accepted practice.
- Removed the Faker dependency (it didn't appear to be used in the codebase and has been sunset).
- Apply PSR-2 Linter to Codebase, using tabs instead of spaces
- Rename QueryPath fork and prepare for publishing on Packagist
-
3.1.428 Mar 2022Release notes
Open source →- Added return types to getIterator() and count() for compatibility with PHP 8.1
-
3.1.305 Aug 2018 -
3.1.204 Aug 2018 -
3.1.103 Aug 2018 -
3.1.002 Aug 2018Release notes
Open source →Transform library for PHP>=7.1 support + essential bug-fixes
- Add strict types passed for parameters
- Add return types scalar/boxed
- Refactor code to OOP (DRY/KISS/SOLID/YAGNI) style - minor to be continued...
- Remove redundant code
- Remove redundant ops
- Fix bugs with equations
- Fix juggling equations
- Fix priority ops in flow structs
- Remove unused vars from stack
-
3.0.501 Aug 2016Nothing published for this version
-
3.0.410 Oct 2015Release notes
Open source →- Addition of namespace fetching method ns().
- Various fixes
- Basic support for HTML5 via Masterminds\HTML5
- Fixed #164
-
3.0.323 Sep 2014Release notes
Open source →- Bug #141: Fixed :gt and :lt pseudoclasses (thanks to lsv)
- Bug #124: Fixed inheritance issue with late static binding (via noisan)
- Bug #126: text(string) was not updating all matched elements (via noisan)
- Bug #127: wrapInner() was mangling the HTML if matched element set was greater than 1 (via noisan)
- Bug #128: Improved jQuery compatibility with wrap*() *pend(), before(), after(), etc. (via noisan)
-
3.0.224 May 2013Release notes
Open source →- Bug #112: children() was not correctly restricting filters.
- Bug #108: QueryPath\Query interface was too restrictive. (via mkalkbrenner)
- Feature #106: :contains() is now case-insensitive. (via katzwebservices)
-
3.0.108 Mar 2013Release notes
Open source →- Issue #100: qp.php divided into qp.php and qp_functions.php. Composer now includes qp(). (via hakre)
- Issue #102: Added QueryPath.VERSION_MAJOR, changed QueryPath.VERSION
- Issue #97: Rewrite children() and filter() to be a little more efficient.
-
3.0.011 Dec 2012Release notes
Open source →-
REALLY IMPORTANT CHANGE: To match jQuery, and to correctly implement a bottom-up parser, the following will no longer work: $qp($html, 'li')->find(':root ul'); You can no longer use find() to ever, ever move UP the document true (like back to the root from somewhere in the tree). You MUST use top() to do this now. This is how jQuery works, and making this minor change makes things much faster.
-
REALLY IMPORTANT CHANGE: Many "destructive" operations now return a new QueryPath object. This mirrors jQuery's behavior.
THAT MEANS: find() now works like jQuery find(), branch() is deprecated. findInPlace() does what find() used to do.
-
removeAll() now works as it does in recent jQuery. Thanks to GDMac (issues #77 #78) for the fix.
-
Refactored to use namespaces.
-
Refactored to be SPR-0 compliant.
-
Now uses Composer.
-
The traversal mechanism is now bottom-up, which means Querypath is faster.
-
Issue #83: Fixed broken forloop in techniques.php. Thanks to BillOrtell for the fix.
-
ID-based searches no longer guarantee that only one element will be returned. This accomodates XML documents that may use 'id' in a way different than HTML.
-
The base CSS Traverser is now optimized for selectors that use ID or class, but no element.
-
Pseudo-element behavior has been rewritten to better conform to the standard. Using a pseudo-element no longer changes the match. Rather, it checks to see if the condition is met by the present element, and returns TRUE if it does. This means we do not need special case logic to deal with text fragments.
-
:x-root, :x-reset, and :scope are now implemented using the same algorithm (they are, in other words, aliases). Since :scope is part of CSS 4, you should use that.
-
Support for the following CSS 4 Selectors featues has been added:
- :matches() pseudoclass, which behaves the way :has() behaves.
- :any-link
- :local-link (with some restrictions, as it does not know what the real URL of the document is).
- :scope (see above)
-
Traversing UP the DOM tree with find() is no longer allowed. Use top().
-
:first is an alias of :nth(1) instead of :first-of-type. This follows jQuery now.
-
eachLambda() is now deprecated. It WILL be removed in the future.
-
Extensions: QPList, QPTPL, and QPDB have all been moved to the new project QueryPath-Ext.
-
-
3.0.0-alpha301 Sep 2012 pre-releaseNothing published for this version
-
3.0.0-alpha225 Jun 2012 pre-releaseNothing published for this version
-
3.0.0-alpha101 Jun 2012 pre-releaseNothing published for this version
-
2.1.203 Feb 2012Release notes
Open source →- Fixed the case where remove() caused an error when no items were found to remove (issue #63). Thanks marktheunissen for the bug report and fix.
- New XML extensions to deal with adding namespaced elements (#64). Thanks to theshadow for contributing an entire extension, and to farinspace for detailed experiments with QP and XML namespaces.
- The adjacent CSS selector has been modified to ignore text elements. This seems to be inline with the spec, but I am not 100% sure. Thanks to fiveminuteargument for the patch.