Date: Tuesday, November 8, 2005 @ 16:21:45
Author: marc
Path: /cvsroot/carob/carob/doc
Removed: HOWTO-PHP-EXTENSION (1.1)
Moved PHP HOWTO to new contrib/PHP directory.
---------------------+
HOWTO-PHP-EXTENSION | 73 --------------------------------------------------
1 files changed, 73 deletions(-)
Index: carob/doc/HOWTO-PHP-EXTENSION
diff -u carob/doc/HOWTO-PHP-EXTENSION:1.1 carob/doc/HOWTO-PHP-EXTENSION:removed
--- carob/doc/HOWTO-PHP-EXTENSION:1.1 Thu Oct 20 03:01:01 2005
+++ carob/doc/HOWTO-PHP-EXTENSION Tue Nov 8 16:21:45 2005
@@ -1,73 +0,0 @@
-This file describe how to write in C++ a PHP5 extension module dynamically
-linked to libcarob. Most of it probably applies to PHP4 as well. Using
-static linking instead of dynamic should be even easier.
-
-First you must be familiar with how to write in C a simple PHP5 module.
-References:
- http://www.zend.com/php/internals/
- http://www.php.net/manual/en/zend.php
-
-The only two additional issues described are:
-- your PHP module (a library) must be linked to libcarob (another library)
-- your PHP module has to be written in C++, but linked using C symbols to
- the PHP engine.
-
-
-1) First there is a small bug in the phpize script, so you must
-slighty patch the "./configure" file generated. The .configure file
-correctly calls the C++ compiler to compile "your_php_module.cpp", but
-unfortunately still calls the C compiler to link it. Search for the
-"link_cmd=" definition inside "./configure" and just replace "$(CC)"
-by "$(CXX).
-
-
-2) Since the PHP engine is written in C, you must take care that:
-- all symbols of your C++ module are exported in a way compatible with C
-- all PHP symbols imported by your C++ module are known as coming from C
-
-In order to do this you have to include all the declarations of those
-symbols inside an "extern C" scope. Your .h files must look like this:
-
- #include "php.h" // no need to worry since this is .h is
- // fortunately already C/C++ compatible.
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- PHP_FUNCTION(hello_world);
- PHP_FUNCTION(hello_greetme);
-
- extern zend_module_entry hello_module_entry;
-
- #ifdef __cplusplus
- } // extern "C"
- #endif
-
-This trick is only needed at declaration time. Once the compiler knows
-this is a C-compatible symbol you can then use it just like a regular
-C++ symbol. This is a very well-known C/C++ linking issue and you'll
-easily find plenty of literature about it.
-
-Additional issue with PHP4:
-With PHP4, you also have to enclose the ZEND_GET_MODULE(module_name) call
-like this:
-
- extern "C" {
- #ifdef COMPILE_DL_HELLO
- ZEND_GET_MODULE(hello)
- #endif
- }
-(thanks to Sara Goleman for the tip)
-
-
-3) Finally the libcarob library must be found by your module: - at
- compile+link time; - again at run-time.
-
-To achieve this simply just add the following EXTRA_LDFLAGS when
-compiling your C++ PHP module:
-
-export CAROB_INSTALL_DIR=/usr/local/lib/my_carob_install
-make EXTRA_LDFLAGS="-L${CAROB_INSTALL_DIR} -lcarobcpp -Wl,--rpath,
-Wl,${CAROB_INSTALL_DIR}"
-
-
_______________________________________________
Carob-commits mailing list
[EMAIL PROTECTED]
https://forge.continuent.org/mailman/listinfo/carob-commits