Install & Compatibility
Where this runs
tested against v1.2.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.1MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
phply.phpast
✓ from phply import phpast
The AST module is phpast, not phply.ast or phply.phpast as a top-level import.
phply.lexer
✓ from phply import phplex
✗ from phply import lexer
The lexer module is named phplex, not lexer.
phply.parser
✓ from phply import phpparse
✗ from phply import parser
The parser module is named phpparse, not parser.
Basic usage: tokenize and parse a PHP snippet.
from phply import phplex, phpparse
from phply import phpast as ast
code = '<?php echo "Hello, World!"; ?>'
tokens = list(phplex.lex(code))
print('Tokens:', tokens)
parser = phpparse.make_parser()
parsetree = parser.parse(code, lexer=phplex.lexer)
print('AST:', parsetree)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'ply'
PLY is a required dependency but not automatically installed.
fixRun 'pip install ply'.
ImportError: cannot import name 'lexer' from 'phply'
Incorrect import path; lexer is actually in 'phplex'.
fixUse 'from phply import phplex' instead.
AttributeError: module 'phply' has no attribute 'phpast'
Trying 'import phply' then 'phply.phpast', but phpast is a submodule.
fixUse 'from phply import phpast'.
Upgrade
Version history
1.2.6latest on PyPI · released Jan 6, 2023
Audit
Dependencies
No dependency data recorded yet.