Enhanced fork of phply — fixes core AST bugs, supports PHP 5.6 through 8.5 syntax.
pip install lphplyNote: Since the internal package name of
lphplyis stillphply, it conflicts with the upstreamviraptor/phplyPyPI package. If you have previously installedphply, please uninstall it first:pip uninstall phply && pip install lphply.
from phply.phplex import lexer
lexer.input('<?php echo "Hello, World!"; ?>')
for token in lexer:
print(token)from phply.phplex import lexer
from phply.phpparse import make_parser
parser = make_parser()
with open('example.php', 'r') as f:
code = f.read()
result = parser.parse(code, lexer=lexer)# Parse a PHP file
phpparse file.php
# Lex a PHP file
phplex file.phpClone the repository and install in development mode:
git clone https://github.com/LoRexxar/Lphply.git
cd Lphply
pip install -e ".[test]"pytestBSD-3-Clause. See LICENSE for details.
Fork of viraptor/phply, originally by Dave Benjamin.