# php2py
[![image](https://img.shields.io/pypi/v/php2py.svg)](https://pypi.python.org/pypi/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
```bash
poetry shell
poetry install
composer install
```
### For actual use
This should work:
```bash
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 `unparse` from 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
- <https://github.com/nicolasrod/php2python>
## 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](https://cruft.github.io/cruft/) and the
[abilian/cookiecutter-abilian-python](https://github.com/abilian/cookiecutter-abilian-python)
project template.
This project uses the `nikic/php-parser` PHP parser (in PHP).
Raw data
{
"_id": null,
"home_page": "https://github.com/sfermigier/php2py",
"name": "php2py",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4",
"maintainer_email": "",
"keywords": "",
"author": "Abilian SAS",
"author_email": "sf@abilian.com",
"download_url": "https://files.pythonhosted.org/packages/c4/eb/3ec8b9a0e01d0fbfd84b371a147ab6f4848d951dfd59378283b2d6c83064/php2py-0.2.0.tar.gz",
"platform": null,
"description": "# php2py\n\n[![image](https://img.shields.io/pypi/v/php2py.svg)](https://pypi.python.org/pypi/php2py)\n\nPHP to Python transpiler.\n\n- Free software: GNU General Public License v3\n\n## Use cases\n\n- Helping port PHP code to Python (provides a first pass, which can then be\n manually edited).\n\n## Features\n\n- Translates a subset of PHP to Python. \n\n## Install\n\n- You need PHP and composer installed on your system.\n- You need Python 3.10+.\n\n### For development\n\n- From a git checkout, run\n\n```bash\npoetry shell\npoetry install\ncomposer install\n```\n\n### For actual use\n\nThis should work:\n\n```bash\npipx install php2py\n```\n\n## Architecture\n\n- Front-end (PHP parser): uses an external PHP parser (nikic/php-parser) to\n parse PHP code and build an AST.\n- Back-end (Python generator): uses the AST to generate Python code, via pattern matching.\n- Python code is generated from AST using the `unparse` from the stdlib.\n\n## TODO\n\n- Add test cases (real programs) and make sure they pass.\n- Make a runtime / stdlib of common PHP functions in Python.\n- Cleanup.\n\n## Prior art\n\n- <https://github.com/nicolasrod/php2python>\n\n## Contributing\n\nI don't have time to work on this project ATM, but I'm happy to review pull requests.\n\nIf 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>).\n\nIf 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/>.\n\n## Credits\n\nThis package was created with [Cruft](https://cruft.github.io/cruft/) and the\n[abilian/cookiecutter-abilian-python](https://github.com/abilian/cookiecutter-abilian-python)\nproject template.\n\nThis project uses the `nikic/php-parser` PHP parser (in PHP).\n\n",
"bugtrack_url": null,
"license": "",
"summary": "PHP to Python transpiler.",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/sfermigier/php2py"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c9ec12b34e8ea686a8b8491aed78a3f05b706ff718a0e6f5f0352ca117ddc535",
"md5": "bc168b2b4b534dec6096cf4fc0ea59ac",
"sha256": "16a5ceb3c5e74d5101fb7a816f1432596ae4ac793e4a7ebebe7930f8ac3edc02"
},
"downloads": -1,
"filename": "php2py-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bc168b2b4b534dec6096cf4fc0ea59ac",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4",
"size": 20023,
"upload_time": "2023-06-06T20:56:36",
"upload_time_iso_8601": "2023-06-06T20:56:36.648267Z",
"url": "https://files.pythonhosted.org/packages/c9/ec/12b34e8ea686a8b8491aed78a3f05b706ff718a0e6f5f0352ca117ddc535/php2py-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c4eb3ec8b9a0e01d0fbfd84b371a147ab6f4848d951dfd59378283b2d6c83064",
"md5": "a014c2bcc9ef6058e98501f622da2d2e",
"sha256": "8a5356bda5793efe6b097cd01939f900c513fe96c2661665081a41a38f502f37"
},
"downloads": -1,
"filename": "php2py-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "a014c2bcc9ef6058e98501f622da2d2e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4",
"size": 28836,
"upload_time": "2023-06-06T20:56:41",
"upload_time_iso_8601": "2023-06-06T20:56:41.269543Z",
"url": "https://files.pythonhosted.org/packages/c4/eb/3ec8b9a0e01d0fbfd84b371a147ab6f4848d951dfd59378283b2d6c83064/php2py-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-06 20:56:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sfermigier",
"github_project": "php2py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "php2py"
}