[PHP] Custom PHP extension: Invalid library (maybe not a PHP library)
Hi all! I'm interested in creating a custom PHP extension. I have found several so called tutorials, but the code examples they contain do not work for me. Let's stick to this site: http://devzone.zend.com/303/extension-writing-part-i-introduction-to-php-and-zend/ Basing on it I have following sources: # config.m4: PHP_ARG_ENABLE(hello2,whether to enable hello2 support, [ --enable-hello2Enable hello2 support]) if test $PHP_HELLO2 = yes; then AC_DEFINE(HAVE_HELLO2,1,[Whether you want hello2 support]) PHP_NEW_EXTENSION(hello2, php_hello2.c, $ext_shared) fi # # php_hello2.h: #ifndef PHP_HELLO2_H #define PHP_HELLO2_H 1 #define PHP_HELLO_WORLD_VERSION 1.0 #define PHP_HELLO_WORLD_EXTNAME hello2 PHP_FUNCTION(hello_world); extern zend_module_entry hello2_module_entry; #define phpext_hello2_ptr hello2_module_entry #endif # # php_hello2.c: #ifdef HAVE_CONFIG_H #include config.h #endif #include php.h #include php_hello2.h static function_entry hello2_functions[] = { PHP_FE(hello_world, NULL) {NULL, NULL, NULL} }; zend_module_entry hello2_module_entry = { #if ZEND_MODULE_API_NO = 20010901 STANDARD_MODULE_HEADER, #endif PHP_HELLO_WORLD_EXTNAME, hello2_functions, NULL, NULL, NULL, NULL, NULL, #if ZEND_MODULE_API_NO = 20010901 PHP_HELLO_WORLD_VERSION, #endif STANDARD_MODULE_PROPERTIES }; #ifdef COMPILE_DL_HELLO2 ZEND_GET_MODULE(hello2) #endif PHP_FUNCTION(hello_world) { RETURN_STRING(Hello World, 1); } # The code compiles well with these commands: $ ./configure --enable-hello2 $ make -j5 # make install But after I execute the command: $ php5 -dextension=hello2.so -v I get the following output. PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'hello2.so' in Unknown on line 0 What I am missing here? Can someone help me? Thanks in advance. Kind Regards, Sławomir -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Custom PHP extension - Invalid library (maybe not a PHP library)
Hi all! I'm interested in creating a custom PHP extension. I have found several so called tutorials, but the code examples they contain do not work for me. Let's stick to this site: http://devzone.zend.com/303/extension-writing-part-i-introduction-to-php-and-zend/ Basing on it I have following sources: # config.m4: PHP_ARG_ENABLE(hello2,whether to enable hello2 support, [ --enable-hello2Enable hello2 support]) if test $PHP_HELLO2 = yes; then AC_DEFINE(HAVE_HELLO2,1,[Whether you want hello2 support]) PHP_NEW_EXTENSION(hello2, php_hello2.c, $ext_shared) fi # # php_hello2.h: #ifndef PHP_HELLO2_H #define PHP_HELLO2_H 1 #define PHP_HELLO_WORLD_VERSION 1.0 #define PHP_HELLO_WORLD_EXTNAME hello2 PHP_FUNCTION(hello_world); extern zend_module_entry hello2_module_entry; #define phpext_hello2_ptr hello2_module_entry #endif # # php_hello2.c: #ifdef HAVE_CONFIG_H #include config.h #endif #include php.h #include php_hello2.h static function_entry hello2_functions[] = { PHP_FE(hello_world, NULL) {NULL, NULL, NULL} }; zend_module_entry hello2_module_entry = { #if ZEND_MODULE_API_NO = 20010901 STANDARD_MODULE_HEADER, #endif PHP_HELLO_WORLD_EXTNAME, hello2_functions, NULL, NULL, NULL, NULL, NULL, #if ZEND_MODULE_API_NO = 20010901 PHP_HELLO_WORLD_VERSION, #endif STANDARD_MODULE_PROPERTIES }; #ifdef COMPILE_DL_HELLO2 ZEND_GET_MODULE(hello2) #endif PHP_FUNCTION(hello_world) { RETURN_STRING(Hello World, 1); } # The code compiles well with these commands: $ ./configure --enable-hello2 $ make -j5 # make install But after I execute the command: $ php5 -dextension=hello2.so -v I get the following output. PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'hello2.so' in Unknown on line 0 What I am missing here? Can someone help me? Thanks in advance. Kind Regards, Sławomir -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom PHP extension: Invalid library (maybe not a PHP library)
The code compiles well with these commands: $ ./configure --enable-hello2 $ make -j5 # make install It's a long time since I built PHP extensions, but aren't you supposed to run phpize before configure? But after I execute the command: $ php5 -dextension=hello2.so -v I get the following output. PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'hello2.so' in Unknown on line 0 What I am missing here? Can someone help me? Thanks in advance. Have you tried google? I found this comment on the PHP sites[1], and it says that the module didn't work when copied into the apache directory, but make install worked fine for him - Matijn [1] http://www.php.net/manual/en/ref.ssh2.php#67197 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom PHP extension: Invalid library (maybe not a PHP library)
Yes, you are right. But that was not the case. Actually, the problem was that I had two PHP packages installed. $PATH modification worked fine for me. Kind Regards, Sławomir W dniu 29 lutego 2012 14:51 użytkownik Matijn Woudt tijn...@gmail.com napisał: The code compiles well with these commands: $ ./configure --enable-hello2 $ make -j5 # make install It's a long time since I built PHP extensions, but aren't you supposed to run phpize before configure? But after I execute the command: $ php5 -dextension=hello2.so -v I get the following output. PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'hello2.so' in Unknown on line 0 What I am missing here? Can someone help me? Thanks in advance. Have you tried google? I found this comment on the PHP sites[1], and it says that the module didn't work when copied into the apache directory, but make install worked fine for him - Matijn [1] http://www.php.net/manual/en/ref.ssh2.php#67197 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Custom php extension
Hello, I've written a small extension, which helps me to debug weird code behaviour in my framework. Anyway I want to improve it, and i'm stuck. I need to get some informations about request in PHP_RINIT_FUNCTION and in PHP_MSHUTDOWN_FUNCTION. I need to get info from _SERVER , _GET and _POST arrays, but i'm unable to do it. Every result of use PG(http_globals)[TRACK_VARS_SERVER] or on get/post is just NULL in zend_print_zval_r (). Any suggestions how to do it? Another question. My extension checks some php.ini settings, and if they are set in wrong way ( register globals, safe mode, etc. ) I want to kill execution of script with message bad ini settings ( or something like that ), AND this also should occures in RINIT or MSHUTDOWN. I'll be very appreciate for any help. Best, KA. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Custom php extension
Hello, I've written a small extension, which helps me to debug weird code behaviour in my framework. Anyway I want to improve it, and i'm stuck. I need to get some informations about request in PHP_RINIT_FUNCTION and in PHP_MSHUTDOWN_FUNCTION. I need to get info from _SERVER , _GET and _POST arrays, but i'm unable to do it. Every result of use PG(http_globals)[TRACK_VARS_SERVER] or on get/post is just NULL in zend_print_zval_r (). Any suggestions how to do it? Another question. My extension checks some php.ini settings, and if they are set in wrong way ( register globals, safe mode, etc. ) I want to kill execution of script with message bad ini settings ( or something like that ), AND this also should occures in RINIT or MSHUTDOWN. I'll be very appreciate for any help. Best, KA. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php