embedded-scripting-languages icon indicating copy to clipboard operation
embedded-scripting-languages copied to clipboard

Add PHP (Embed SAPI)

Open cubiclesoft opened this issue 3 years ago • 1 comments
trafficstars

I don't see PHP or PHP (Embed SAPI) in the list. PH7 seems to be listed but is basically a dead project.

It's a little known fact that a PHP SAPI ("Server" API) can be compiled specifically for embedding full PHP scripting engine support into other C/C++ software applications: --enable-embed[=static] at compile time generates the embed SAPI. From there, just include the appropriate header files and link against the library during compilation. For non-C/C++ languages, the language will probably need a C shim that adds a small translation layer. PHP is VERY macro-heavy, which means trying to correctly import shared library exports is not a really great idea.

Since embedding support is already included with the PHP language itself, I guess just link to www.php.net?

https://www.phpinternalsbook.com/php7/build_system/building_php.html

include/php contains header files, which are needed to build additional extensions or embed PHP in custom software.

The macro PHP_EMBED_START_BLOCK seems to be the magic Google/GitHub/StackOverflow search engine keyword that turns up sample working code snippets. For example, I got this:

https://stackoverflow.com/questions/73345686/store-output-of-php-execute-script

cubiclesoft avatar Nov 10 '22 15:11 cubiclesoft

@cubiclesoft Since this seems nuanced, and I am not familiar with embedding PHP, could you PR an entry for PHP with a good "notes" column? (Do not edit README.md directly. Add the information to data/projects.toml.)

dbohdan avatar Aug 28 '23 08:08 dbohdan