Skip to content

LoRexxar/Lphply

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

307 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phply

PyPI version PyPI - Python Version GitHub release License

Enhanced fork of phply — fixes core AST bugs, supports PHP 5.6 through 8.5 syntax.

Installation

pip install lphply

Note: Since the internal package name of lphply is still phply, it conflicts with the upstream viraptor/phply PyPI package. If you have previously installed phply, please uninstall it first: pip uninstall phply && pip install lphply.

Usage

Lexer

from phply.phplex import lexer

lexer.input('<?php echo "Hello, World!"; ?>')
for token in lexer:
    print(token)

Parser

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)

Command-line tools

# Parse a PHP file
phpparse file.php

# Lex a PHP file
phplex file.php

Development

Clone the repository and install in development mode:

git clone https://github.com/LoRexxar/Lphply.git
cd Lphply
pip install -e ".[test]"

Running tests

pytest

License

BSD-3-Clause. See LICENSE for details.

Credits

Fork of viraptor/phply, originally by Dave Benjamin.

About

Pure Python PHPparser, base on phply

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors