php2py
PHP to Python transpiler.
- Free software: GNU General Public License v3
Use cases
- Helping port PHP code to Python (provides a first pass, which can then be manually edited).
Features
- Translates a subset of PHP to Python.
Install
- You need PHP and composer installed on your system.
- You need Python 3.10+.
For development
- From a git checkout, run
poetry shell
poetry install
composer install
For actual use
This should work:
pipx install php2py
Architecture
- Front-end (PHP parser): uses an external PHP parser (nikic/php-parser) to parse PHP code and build an AST.
- Back-end (Python generator): uses the AST to generate Python code, via pattern matching.
- Python code is generated from AST using the
unparsefrom the stdlib.
TODO
- Add test cases (real programs) and make sure they pass.
- Make a runtime / stdlib of common PHP functions in Python.
- Cleanup.
Prior art
Contributing
I don't have time to work on this project ATM, but I'm happy to review pull requests.
If you are a student (or a group of students) in a computer science or engineering program, and you want to work on this, please contact me (mailto:sf@abilian.com).
If you think this project can be useful for your company, you can support the development effort through a sponsorship via my company, Abilian: https://abilian.com/.
Credits
This package was created with Cruft and the abilian/cookiecutter-abilian-python project template.
This project uses the nikic/php-parser PHP parser (in PHP).
Metadata
Release files for php2py 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| php2py-0.2.0.tar.gz | 28.8 kB | Without provenance | Details for php2py-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| php2py-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for php2py-0.2.0-py3-none-any.whl |
Total release size: 48.9 kB
Release files / php2py-0.2.0.tar.gz
| Download URL | php2py-0.2.0.tar.gz |
|---|---|
| Size | 28.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a5356bda5793efe6b097cd01939f900c513fe96c2661665081a41a38f502f37
|
|
BLAKE2b-256 checksum How to use checksums |
c4eb3ec8b9a0e01d0fbfd84b371a147ab6f4848d951dfd59378283b2d6c83064
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / php2py-0.2.0-py3-none-any.whl
| Download URL | php2py-0.2.0-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16a5ceb3c5e74d5101fb7a816f1432596ae4ac793e4a7ebebe7930f8ac3edc02
|
|
BLAKE2b-256 checksum How to use checksums |
c9ec12b34e8ea686a8b8491aed78a3f05b706ff718a0e6f5f0352ca117ddc535
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for php2py 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.