https://github.com/marella/phython
Call Python modules and functions from PHP.
https://github.com/marella/phython
Last synced: about 1 year ago
JSON representation
Call Python modules and functions from PHP.
- Host: GitHub
- URL: https://github.com/marella/phython
- Owner: marella
- License: mit
- Created: 2016-12-17T20:41:21.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-20T15:25:47.000Z (over 9 years ago)
- Last Synced: 2025-02-06T12:15:57.623Z (over 1 year ago)
- Language: PHP
- Size: 19.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Phython
[](https://coveralls.io/github/marella/phython?branch=master)
[](https://travis-ci.org/marella/phython)
[](https://styleci.io/repos/76745760)
[](https://packagist.org/packages/marella/phython) [](https://packagist.org/packages/marella/phython) [](https://packagist.org/packages/marella/phython) [](https://packagist.org/packages/marella/phython)
Call Python modules and functions from PHP.
### Quick Usage
```sh
composer require marella/phython
```
```php
from('array')->import('sort');
// call python function and get its return value
$sorted = $sort($array); // [1, 2, 3, 4, 5]
// multiple arguments
$reversed = $sort($array, /* reverse */ true); // [5, 4, 3, 2, 1]
// asynchronous call
$process = $sort->async($array); // background python process object
// do other stuff
$sorted = $process->output(); // [1, 2, 3, 4, 5] (waits till python function returns)
```
where `array.py` contains `sort` function:
```py
def sort(array, reverse=False):
array.sort()
if reverse:
array.reverse()
return array
```
### Documentation
See the **[wiki]** for more details and documentation.
### Contributing
See [contributing guidelines] before creating issues or pull requests.
### License
Open-source software released under [the MIT license][license].
[wiki]: https://github.com/marella/phython/wiki
[contributing guidelines]: /.github/CONTRIBUTING.md
[license]: /LICENSE