Skip to main content

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lphply-2.2.1.tar.gz (95.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lphply-2.2.1-py3-none-any.whl (85.3 kB view details)

Uploaded Python 3

File details

Details for the file lphply-2.2.1.tar.gz.

File metadata

  • Download URL: lphply-2.2.1.tar.gz
  • Upload date:
  • Size: 95.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for lphply-2.2.1.tar.gz
Algorithm Hash digest
SHA256 f1f8bef8f9fe866c6a62aecc56a15d47a20fe91a10b514ffcdba306a9147a876
MD5 ac5fcc6bcdbb73a35239b06221d51279
BLAKE2b-256 824d1baefc3981b37a3179241dba531d78810b227e6b272f359758f4a4747fca

See more details on using hashes here.

File details

Details for the file lphply-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: lphply-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 85.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for lphply-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5dc8b8c104fd871176074242ef044b07585054402a6fb992a7781ead253800c
MD5 3bff84e58a5c83e2f5c9659d0d750752
BLAKE2b-256 cc2f1482940a8407a9ed0d027c56af0e8dad3e6d4875ec05abc794faf128d7be

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.2.1 This release

2 files

2.2.0

2 files

2.1.0

2 files

2.0.0

2 files

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