Skip to main content

php-parser-py

PHP's parser, in py - Drive nikic/PHP-Parser from Python.

Parse, query, mutate, and regenerate PHP code in Python through a graph API.

Install

# via uv
uv add php-parser-py

# or via pip
pip install php-parser-py

Requires Python >= 3.10.

Usage

from pathlib import Path
from tempfile import TemporaryDirectory

from php_parser_py import PHPVersion, StandardPrinter, parse_file

with TemporaryDirectory() as directory:
    path = Path(directory) / "example.php"
    path.write_text("<?php echo 1;", encoding="utf-8")
    ast = parse_file(str(path), target_php=PHPVersion(8, 3))
    echoes = list(ast.nodes(lambda node: node.node_type == "Stmt_Echo"))
    print(next(iter(StandardPrinter().print(ast).values())))

API

Documentation

  • Concepts — problem scope, data flow, and core terminology.
  • Design — architecture, class specifications, and mapping rules.
  • AST Reference — complete table of PHP-Parser node types.
  • cpg2py API — graph querying patterns.

For Agents

Agent-consumable documentation index at docs/llms.txt (llmstxt.org format).

License

GPL-2.0-only — see LICENSE.

Metadata

Release files for php-parser-py 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for php-parser-py 2.1.0
File Actions
php_parser_py-2.1.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for php_parser_py-2.1.0-py3-none-win_amd64.whl
php_parser_py-2.1.0-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for php_parser_py-2.1.0-py3-none-manylinux_2_17_x86_64.whl
php_parser_py-2.1.0-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for php_parser_py-2.1.0-py3-none-manylinux_2_17_aarch64.whl
php_parser_py-2.1.0-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details for php_parser_py-2.1.0-py3-none-macosx_11_0_x86_64.whl
php_parser_py-2.1.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for php_parser_py-2.1.0-py3-none-macosx_11_0_arm64.whl

Total release size: 17.3 MB

Release files / php_parser_py-2.1.0-py3-none-win_amd64.whl

Download URL php_parser_py-2.1.0-py3-none-win_amd64.whl
Size 3.8 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
c7c7d82e4cf843252fb275a032a84cf2f4371b4c118b4b9945ecec0dfc446cf0
BLAKE2b-256 checksum
How to use checksums
5192b3de853564bb348a1ee3919cf012cf5307540a6fbdea47e7c5de56fb4e54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / php_parser_py-2.1.0-py3-none-manylinux_2_17_x86_64.whl

Download URL php_parser_py-2.1.0-py3-none-manylinux_2_17_x86_64.whl
Size 3.3 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
65a8feb182923c5893ec799e8d539fffd8cc809a227b44916dd4ee618c291b47
BLAKE2b-256 checksum
How to use checksums
6fe79506634b6a3f734487325363bde4b4999661c593134aa7a2cfccabe94839
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / php_parser_py-2.1.0-py3-none-manylinux_2_17_aarch64.whl

Download URL php_parser_py-2.1.0-py3-none-manylinux_2_17_aarch64.whl
Size 3.3 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
5431ca53282316ce7ba188f8e34f5b31794ae814179f97eeaf6c76acdc13a563
BLAKE2b-256 checksum
How to use checksums
0137052d43cd7bd6075fdb9cb38ef216ac4d632415a1b70c3be4106250bfda9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / php_parser_py-2.1.0-py3-none-macosx_11_0_x86_64.whl

Download URL php_parser_py-2.1.0-py3-none-macosx_11_0_x86_64.whl
Size 3.6 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
6e8a10a3cdb2f91621cbd9b32fab72dcb0d722f623378f2118cf6b15f8707424
BLAKE2b-256 checksum
How to use checksums
5329d3a4a8133790308247ad4d2f67c40d8d73221d008bf89e234f78f371d0ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / php_parser_py-2.1.0-py3-none-macosx_11_0_arm64.whl

Download URL php_parser_py-2.1.0-py3-none-macosx_11_0_arm64.whl
Size 3.4 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
27b38640bbb2648a65b8e074528c15cd9ec8a36a1f779d51a4a462f491c46096
BLAKE2b-256 checksum
How to use checksums
c38ddf0f686b12bbeba52a7d970a0903f49e59cf2a0a49001238f45e63f33f49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for php-parser-py 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page