Skip to content
This repository

Embedded Python Extension for PHP

branch: master
Octocat-spinner-32 docs Removing the executable bit from these text files. September 04, 2012
Octocat-spinner-32 examples Registering a PHP_PYTHON_VERSION constant that contains the extension's September 22, 2008
Octocat-spinner-32 tests Recognize version strings for Python development builds and Stackless… February 23, 2009
Octocat-spinner-32 .gitignore Flesh out the .gitignore file. September 09, 2012
Octocat-spinner-32 CREDITS Add my embedded Python extension to PECL. This does not represent a full July 29, 2002
Octocat-spinner-32 EXPERIMENTAL Add my embedded Python extension to PECL. This does not represent a full July 29, 2002
Octocat-spinner-32 LICENSE Add a formal copy of the MIT license. September 04, 2012
Octocat-spinner-32 README.md Add an initial README file. September 04, 2012
Octocat-spinner-32 config.m4 Implementing initial support for intercepting Python streams. By defa… October 04, 2008
Octocat-spinner-32 config.w32 Implementing initial support for intercepting Python streams. By defa… October 04, 2008
Octocat-spinner-32 package.php Add a formal copy of the MIT license. September 04, 2012
Octocat-spinner-32 package.xml Updating the package file to reflect the new PHP 5.3 dependency. February 24, 2009
Octocat-spinner-32 php_python.h Updating the extension's version number of removing the CVS Revision … September 22, 2008
Octocat-spinner-32 php_python_internal.h Address some integer type mismatches. September 09, 2012
Octocat-spinner-32 python.c s,function_entry,zend_function_entry, March 31, 2010
Octocat-spinner-32 python_convert.c Address some integer type mismatches. September 09, 2012
Octocat-spinner-32 python_handlers.c Address some assignment-related compiler warnings. September 09, 2012
Octocat-spinner-32 python_object.c Address some assignment-related compiler warnings. September 09, 2012
Octocat-spinner-32 python_php.c Improved parameter handling. January 19, 2009
Octocat-spinner-32 python_streams.c Address some integer type mismatches. September 09, 2012
README.md

Python in PHP

Copyright © 2002-2012 Jon Parise

Overview

This code is released under the terms of the MIT License.

Requirements

The Python extension has the following system requirements:

  • PHP version 5.2.0 or later
  • PEAR installer version 1.4.3 or later

Installation

The easiest way to install the Perforce extension is by using the PECL installer::

pecl install python

If you're building from source code, should use the --with-python configuration option. If your copy of the Python hasn't been installed in one of the default locations, you can specify it as a parameter::

--with-python=/opt/python

More detailed information on installing PECL packages in general can be found in the Installation of PECL Extensions section of the PHP Manual.

Source Code

This package's source code is hosted on GitHub:

https://github.com/jparise/php-python.git

A number of unit tests are included to help maintain correct and expected behavior. The tests can be run using PECL tool's run-tests command:

pecl run-tests -p python

Additional unit test contributions are welcome, especially when they increase code coverage or exercise specific use cases.

Usage

INI Settings

python.optimize

The python.optimize INI setting controls the Python interpreter's runtime optimization level. This is a global, system-wide setting and therefore can only be set in the PHP.ini file.

When set to 0 (the default), no additional optimizations are enabled, and the built-in __debug__ flag is True.

When set to 1 (equivalent to Python's -O command line option), the Python interpreter will generate optimized bytecode, and the built-in __debug__ flag is set to False.

When set to 2 (equivalent to Python's -OO command line option), the Python doc-strings will be removed in addition to the above optimizations.

Development and Support

Reporting Problems and Suggestions

If you run into a problem or would like to make a suggestion, please use the issue tracker. Feel free to contact me directly for other issues, but please try to use the bug tracker whenever possible so that others in the community will benefit from your feedback and my responses.

Something went wrong with that request. Please try again.