LinuxCommandLibrary

phpquery

Query PHP configuration and information

TLDR

List available PHP versions

$ sudo phpquery -V
copy

List available SAPIs for PHP 7.3
$ sudo phpquery -v [7.3] -S
copy

List enabled extensions for PHP 7.3 with the cli SAPI
$ sudo phpquery -v [7.3] -s [cli] -M
copy

Check if the JSON extension is enabled for PHP 7.3 with the apache2 SAPI
$ sudo phpquery -v [7.3] -s [apache2] -m [json]
copy

SYNOPSIS

phpquery [options] <input_file> <query_selector>
(Hypothetical; typically used as php -f script.php with phpQuery library loaded.)

PARAMETERS

-h, --help
    Show help and usage.

-v, --version
    Display version info.

-f, --file <file>
    Input HTML/XML file to parse.

-s, --selector <css_selector>
    jQuery-like selector for querying elements.

-o, --output <format>
    Output format: text, html, json.

DESCRIPTION

phpquery is not a standard Linux command. It refers to phpQuery, a PHP library mimicking jQuery for server-side HTML/XML parsing and manipulation. No official CLI binary exists in major distros like Ubuntu or Fedora. Users might create wrappers via php scripts, e.g., php phpquery.php input.html, but it's library-focused.

Originally developed for DOM traversal without browser, it allows CSS selector queries on HTML strings. Common use: scraping, testing HTML. Install via Composer: composer require phpquery/phpquery. Invoke programmatically, not directly as shell command.

Lacks man page; docs at phpquery.net. Alternatives: jq for JSON, pup or htmlq for HTML querying.

CAVEATS

Not in standard repos; requires PHP >=5.3 and manual install. Deprecated since 2015; use DiDOM or Symfony DomCrawler. Potential security risks parsing untrusted HTML. No native binary; always script-wrapped.

INSTALLATION

Via Composer: composer require phpquery/phpquery. Or git clone from GitHub, then php include('phpQuery.php');.

EXAMPLE USAGE

$doc = phpQuery::newDocumentHTMLFile('input.html'); pq('div.title')->text(); (in PHP script).

HISTORY

phpQuery created by Tobiasz Cudnik in 2008 as PHP5 jQuery port. Peaked ~2012 with 1.3.3 release. Maintained sporadically; archived on GitHub. Usage declined with PHP DOM improvements and JS alternatives.

SEE ALSO

php(1), jq(1), pup(1), htmlq(1), xmllint(1)

Copied to clipboard