phply
Lexer and parser for PHP source implemented using PLY
What it is and what it does
phply is a PHP parser built on ply, a lexer/parser generator toolkit. It tokenizes PHP source code and builds abstract syntax trees that represent the program structure. The package includes a lexer that matches PHP's standard token set and a parser covering most of the PHP grammar, plus utility scripts to dump ASTs as JSON or convert PHP templates to Jinja2.
The parser is designed for analysis and transformation tasks—converting PHP code to Python, running PHP templates in Python environments, or studying how industrial languages handle parsing edge cases. It is not a PHP runtime. The package is in a stable but abandoned state; while it has no known vulnerabilities, it receives no active maintenance and will not track PHP language evolution.
Use it for:
- Analyze PHP source code structure and generate ASTs for static analysis tools
- Convert legacy PHP templates to Jinja2 for use in Python web frameworks
- Build PHP-to-Python code migration or transpilation tools
- Study parsing techniques for complex, real-world language grammars
- Extract metadata or patterns from PHP codebases programmatically
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
phply is a lexer and parser for PHP source code that generates abstract syntax trees, enabling PHP code analysis and conversion to other formats like JSON or Jinja2 templates.
Yes, if you need to parse PHP code for analysis or conversion and can accept that the parser may not handle very recent PHP syntax. The low install friction and permissive license make it accessible. No, if you require active maintenance, support for modern PHP versions, or a runtime environment—phply is abandoned and will not evolve with the PHP language.
Install
phply on PyPI
pip
pip install phplyuv
uv add phplypoetry
poetry add phplyInstalling phply
Before you install
Installation is straightforward with a single pure-Python dependency (ply). However, the package is abandoned—last commit was 2023-02-20 and no releases in over 1316 days. It will not receive bug fixes or updates for newly discovered PHP syntax or language features.
License in practice
BSD license is permissive, allowing use in both open-source and proprietary projects with minimal restrictions. You must include a copy of the license and retain authorship notices.
Quickstart
pip install phply
from phply.phplex import PhpLexer
from phply.phpparse import PhpParser
lexer = PhpLexer()
parser = PhpParser()
result = parser.parse('<?php echo "hello"; ?>', lexer=lexer.lexer)
Verify before relying
- Whether the parser handles modern PHP syntax or only older versions
- Completeness of PHP grammar coverage beyond labels and goto statements
- Stability and correctness of the Jinja2 conversion tool for real-world templates
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — ply |
| Maintenance | abandoned — 1,316 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 183,782/month — #10,058 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: phply-1.2.6-py2.py3-none-any.whl
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
plyPLY is a lexer and parser generator for Python…
permissive · top 1,000 on PyPI
slySLY is a pure-Python implementation of lex and…
permissive · top 5,000 on PyPI
rplyRPLY is a pure Python parser generator that…
permissive · top 15,000 on PyPI
tree-sitter-phpProvides a PHP language grammar for…
permissive · top 5,000 on PyPI
ast-decompilerConverts Python abstract syntax trees (ASTs)…
permissive · top 15,000 on PyPI
pycparserpycparser is a C language parser written in…
permissive · top 100 on PyPI
lark-parserLark is a parsing library that builds abstract…
permissive · top 5,000 on PyPI
pygmarsPygmars builds lightweight lexers and parsers…
permissive · top 15,000 on PyPI
php2jsonConverts PHP serialized strings to JSON format,…
permissive · top 15,000 on PyPI
phpserializeConverts Python objects to and from PHP…
permissive · top 15,000 on PyPI