0

It compiles into a DLL w/o problems. But then it's not being recognized as loaded when I use the extension_loaded function in PHP or look it up in the phpinfo list. I put the DLL into the extensions folder then add it's entry into php.ini. I think the problem may be in the code.

Am I missing something or doing something wrong?

ZEND_FUNCTION(MyFunction) 
{

    char var1 = NULL;
    char var2 = NULL;
    char var3 = NULL;
    char var4 = NULL;
    char var5 = NULL;
    char var6 = NULL;
    int var7;
    double *var8;

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssssssla", &var1, &var2,
                                &var3, &var4, &var5, &var6, &var7, &var8) == FAILURE) {
        RETURN_NULL();
    }

    Cfunction(&var1,&var2,&var3,&var4,&var5, &var6, var7, var8);

    RETURN_TRUE;
}

zend_function_entry MyExtension_functions[] = {
    ZEND_FE(MyFunction, NULL)
    {NULL,NULL,NULL}
};


PHP_MINIT_FUNCTION(MyExtension) {
    return SUCCESS;
}

PHP_MSHUTDOWN_FUNCTION(MyExtension) {
    return SUCCESS;
}

PHP_MINFO_FUNCTION(MyExtension) {
    php_info_print_table_start();
    php_info_print_table_header(2, "MyExtension v1.0", "");
    php_info_print_table_row(2, "PHP Extension", "enabled");
    php_info_print_table_end();
} 




zend_module_entry MyExtension_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
    STANDARD_MODULE_HEADER,
#endif
    "MyExtension",
     MyExtension_functions,
    NULL,
    NULL,
    NULL,
    NULL,
    PHP_MINFO(MyExtension),
    "1.0",
    STANDARD_MODULE_PROPERTIES
};

    ZEND_GET_MODULE(MyExtension)
6
  • Did you restart the web server after installing the extension and adding it to php.ini? What error message are you getting? Commented Jul 10, 2013 at 19:31
  • Yes I restarted the web server. An error message from the server or php? Commented Jul 10, 2013 at 19:33
  • sure you're modifying the right .ini file? check phpinfo()'s output to see which one you should be changing. Commented Jul 10, 2013 at 19:35
  • Yes, I'm modifying the right .ini file. I checked phpinfo() to be sure. Commented Jul 10, 2013 at 19:38
  • 1
    enable show_startup_errors in php.ini. Otherwise messages because of faulty extensions will get silenced Commented Jul 10, 2013 at 19:40

1 Answer 1

1

The best way to view extension loading errors is to run php.exe from command line. This showed me error messages of

Warning: PHP Startup: MyExtension: Unable to initialize module
Module compiled with module API=20121212
PHP    compiled with module API=20090626
These options need to match
 in Unknown on line 0

So I found the #define ZEND_MODULE_API_NO in zend_modules.h and changed it from 20121212 to 20090626.

Then it complained with:

Warning: PHP Startup: MyExtension: Unable to initialize module
Module compiled with build ID=API20090626,NTS,VC10
PHP    compiled with build ID=API20090626,NTS,VC9
These options need to match
 in Unknown on line 0

So I found #define PHP_COMPILER_ID in config.w32.h and changed it from "VC10" to "VC9".

After this it loaded the module. I was able to call my function but it came back with a tradition 500 error. I suspect this has something to do with the VC9/VC10 incompatibility.

The moral of the story is that I tried to use extension compiled with VC10 when the PHP I was using was compiled with VC9. This leads to all sorts of errors. The appropriate thing to do is then compile PHP src with VC10.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.