Skip to content

Latest commit

 

History

History
56 lines (36 loc) · 1.21 KB

README.rst

File metadata and controls

56 lines (36 loc) · 1.21 KB

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