phPy is a simple way to call legacy PHP functions from Python.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
phpy
tests
.gitignore
.travis.yml
AUTHORS
LICENSE
README.rst
setup.py

README.rst

phPy

phPy is a simple way to call legacy PHP functions from Python.

Installation

You can install the package from PyPI:

$ pip install phpy

Requirements

phPy uses php5-cli. You have to install the php5-cli package by using apt-get or yum.

$ apt-get install php5-cli
$ yum install php

Example

function LegacyPHPFunction($arg1, $arg2, $arg3) {
    //... original codes...

    $result = array(
        "foo" => $arg1,
        "bar" => $arg2,
    );

    echo json_encode($result);
}
from phpy import PHP

#php_file_path = the path of your legacy php file...
php = PHP(php_file_path)
result_raw = php.get_raw('LegacyPHPFunction', ['argument1',u'argument2', 3]) # get a return value as a raw string
result_dict = php.get_dict('LegacyPHPFunction', ['argument1',u'argument2', 3]) # get return values as a python dictionary
print result_dict['foo']

Continuous Integration (Travis CI)

https://travis-ci.org/leekchan/phpy/

Build Status