I use both PHP in a WAMP environment and code with both C++ and PHP. I'm just trying to develop my first PHP extension (Module), but have reached a brick wall. Maybe someone can help?
I'm running PHP 8.2.8 TS 64-bit through an Apache 2.4.x web server on Windows Server
Visual Studio 2022 using Windows SDK 10 and the same platform API as the PHP (API20220829)
Preprocessor definitions: ZEND_THREAD_SAFE; ZEND_WIN32; PHP_WIN32
Linked to: php8ts.php
Language Standard: ISO C++ 14
Runtime Library: Multi-threaded DLL (/MD)
It compiles, links and dlivers the php_helloworld.dll
I have chosen every option I can to produce a THREAD SAFE version and I am using the downloaded PHP8.2.8 TS 64-bit TS development pack. ( php-devel-pack-8.2.8-Win32-vs16-x64 ).
However, I get the following error every time, telling me it is NON THREAD SAFE.
PHP Warning: PHP Startup: php_helloworld: Unable to initialize module
Module compiled with build ID=API20220829,NTS,VS16
PHP compiled with build ID=API20220829,TS,VS16_
I have tried changes and tweaks to the configuration for 3 days and always the same result.
It is a very simple, single CPP file with following code, just to test it out:
// dllmain.cpp : Defines the entry point for the DLL application.
#define ZEND_DEBUG 0
// Declare the function
// register our function to the PHP API
// so that PHP knows, which functions are in this module
zend_function_entry php_helloworld_functions =
NULL, NULL, NULL
// some pieces of information about our module
zend_module_entry php_helloworld_module_entry =
"php_helloworld", // Extension name
php_helloworld_functions, // Function entry
NULL, // Module initialization
NULL, // Module shutdown
NULL, // Request initialization (not used)
NULL, // Request shutdown (not used)
NULL, // Extension info (not used)
"1.0", // Extension version
// use a macro to output additional C code, to make ext dynamically loadable
// Finally, we implement our "Hello World" function
// this function will be made available to PHP
// and prints to PHP stdout using printf
php_printf("Hello World! (from our extension)\n");
I'm completely stumped, so any positive advice or assistance gratefully received.