-
Notifications
You must be signed in to change notification settings - Fork 12
Home
moriyoshi edited this page Sep 12, 2010
·
39 revisions
Boost.PHP is a set of C++ header files that allows you to create your PHP extension in C++ without any obfuscating ZEND_* / PHP_* macros, like the glorious Boost.Python after which this is loosely designed.
This software is in early beta stages and lots of bugs have been confirmed, though the basic features are almost complete. Please help me improve the software! You can get in touch at mozo [at] mozo [.] jp.
A typical example that defines a couple of user-land functions add() and sub():
#include "boost/php/module.hpp"
#include "boost/php/function.hpp"
using namespace boost;
class m002_module
: public php::module,
public php::function_container<m002_module> {
public:
class handler
: public php::module::handler {
public:
handler(m002_module* mod)
:php::module::handler(mod) {}
int add(int a, int b) {
return a + b;
}
int sub(int a, int b) {
return a - b;
}
};
public:
m002_module(zend_module_entry* entry)
: php::module(entry) {
entry->functions =
defun("add", &handler::add).
defun("sub", &handler::sub);
}
};
#define BOOST_PHP_MODULE_NAME m002
#define BOOST_PHP_MODULE_CAPITALIZED_NAME M002
#define BOOST_PHP_MODULE_VERSION "0.1"
#define BOOST_PHP_MODULE_CLASS_NAME m002_module
#include "boost/php/module_def.hpp"
Want to know more? You can proceed to Tiny Tutorial or Getting Started.
- A working C++ compiler (tested with g++ 4.x).
- PHP version 5.1 or later.
- Boost version 1.34.0 or later.
This software is released under Boost Software License 1.0 .