Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP (Embed SAPI) #70

Open
cubiclesoft opened this issue Nov 10, 2022 · 1 comment
Open

Add PHP (Embed SAPI) #70

cubiclesoft opened this issue Nov 10, 2022 · 1 comment

Comments

@cubiclesoft
Copy link

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

@dbohdan
Copy link
Owner

dbohdan commented Aug 28, 2023

@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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants