Hi all 🙂 , I´m trying to start developing PHP extensions on Windows. I´m using Visual Studio .NET 2003. I have been following some tutorials found in Internet, I have compiled a test extension, but still need to fix something, hope you can help me.
The tutorial is this: hxxp://www.osix.net/modules/article/?id=585
At this point I have prepared all the includes and paths, I have been able to build the dll but nothing is shown about my test extension in phpinfo(), also I cant use test functions defined on my test extension. I have added the extension to extensions directory in PHP and added "extension=php_extend.dll" on php.ini.
I have added the dll on extensions inside PHP´s folder and in Windows/System32, restarted the server many times too.
VStudio warnings:
e:\PHP\Zend\zend_execute.h(92) : warning C4311: 'type cast' : pointer truncation from 'void ' to 'ulong'
e:\PHP\Zend\zend_execute.h(104) : warning C4311: 'type cast' : pointer truncation from 'void ' to 'ulong'
php_extend.c(27) : warning C4013: 'php_info_print_table_start' undefined; assuming extern returning int
php_extend.c(28) : warning C4013: 'php_info_print_table_header' undefined; assuming extern returning int
php_extend.c(29) : warning C4013: 'php_info_print_table_row' undefined; assuming extern returning int
php_extend.c(30) : warning C4013: 'php_info_print_table_end' undefined; assuming extern returning int
After building on VS I receive 6 warnings and 0 errors, the tutorial says some warnings are not important.
When I try to use test functions in php with this php script:
<?PHP
myfirstfunc();
?>
I receive this message:
Fatal error: Call to undefined function: myfirstfunc() in c:\apache\htdocs\extend.php on line 3
Looks like PHP cant found the dll...
C source code follows:
php_extend.h
#define ZEND_WIN32
#define PHP_WIN32
#define ZEND_DEBUG 0
#define COMPILE_DL_EXTEND 1
#define ZTS 1
#include "php.h"
php_extend.c
#include "php_extend.h"
ZEND_FUNCTION(myfirstfunc);
PHP_MINFO_FUNCTION(extend);
zend_function_entry extend_functions[] = {
ZEND_FE(myfirstfunc, NULL)
{NULL, NULL, NULL}
};
zend_module_entry extend_module_entry = {
STANDARD_MODULE_HEADER,
"My first PHP Extension",
extend_functions,
NULL, NULL, NULL, NULL,
PHP_MINFO(extend),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
#if COMPILE_DL_EXTEND
ZEND_GET_MODULE(extend)
#endif
PHP_MINFO_FUNCTION(extend) {
php_info_print_table_start();
php_info_print_table_header(2, "Extend the amazing php extension", "");
php_info_print_table_row(2, "PHP Extension", "enabled");
php_info_print_table_end();
}
ZEND_FUNCTION(myfirstfunc) {
zend_printf("This is my first function");
}
I have also tried using dl(), but it says it doesnt work on multithreaded servers... :bemused:
Hope you can help me, thanks in advance.