Skip to content

🦣 服务器应用程序编程接口 (SAPI) 是 Zend Engine 的入口点。嵌入的 SAPI 是一种轻量级 SAPI,用于从 C 或其他具有 C 绑定的语言调用 Zend Engine。

Notifications You must be signed in to change notification settings

workbunny/static-php-embed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spc build

./spc doctor --auto-fix
./spc build --build-all "amqp,apcu,bcmath,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,gd,gettext,iconv,igbinary,imagick,intl,libxml,mbregex,mbstring,memcache,mongodb,msgpack,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pdo_sqlsrv,pgsql,phar,posix,readline,redis,session,shmop,simdjson,simplexml,soap,sockets,sodium,sqlite3,sqlsrv,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib" --with-upx-pack

修改 buildroot/bin/php-config 文件

#perfix=""
perfix="/path/to/buildroot"

示例一

#include <sapi/embed/php_embed.h>
#define HEREDOC(...) #__VA_ARGS__

int main(int argc,char **argv){
    // php嵌入开始
    PHP_EMBED_START_BLOCK(argc,argv)

    const char *str = HEREDOC(
        echo "世界上最好的语言是PHP!\n";
    );

    // eval执行php代码
    zend_eval_string(str, NULL, "MY PHP APP");

    //php嵌入结束
    PHP_EMBED_END_BLOCK()
    return 0;
}

build.sh 编译

编译器musl-cc

x86_64-linux-musl-cc \
$(./buildroot/bin/php-config --includes) \
-L/usr/lib \
-L$(./buildroot/bin/php-config --prefix)/lib \
cphp.c -o cphp.bin \
-lphp \
$(./buildroot/bin/php-config --libs) \
-lm -lpthread -lresolv -ldl -lc \
-Wl,-rpath=$(./buildroot/bin/php-config --prefix)/lib \
-lpq -lpgport -lpgcommon -lgomp -lstdc++ -static
# -lpq -lpgport -lpgcommon
# -fsanitize=thread -pie -fPIC \

About

🦣 服务器应用程序编程接口 (SAPI) 是 Zend Engine 的入口点。嵌入的 SAPI 是一种轻量级 SAPI,用于从 C 或其他具有 C 绑定的语言调用 Zend Engine。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published