Skip to content
/ phpy Public

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

License

Notifications You must be signed in to change notification settings

leekchan/phpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published