PHP 编译器 BPC 6.2 发布,直接编译 PHP 文件为 web server!

查看 50|回复 1
作者:heguangyu5   
不了解 BPC 是什么的可以翻看之前的帖子.
简言之,BPC 可以将 PHP 代码最终转译成 C 语言,然后编译成动态链接库或者可执行程序,实现 PHP Native AOT.

apache2 mod_bpc
在 BPC 6.2 之前,要想发布 web 应用,需要将 php 文件编译成.so,然后由 BPC 提供的 apache2 module mod_bpc 加载,借由 apache 对外提供服务,详见 07_mod_bpc.
althttpd/althttpd-tls
Althttpd 是 https://sqlite.org/ 背后的 webserver, 其简介如下:

Althttpd is a simple webserver that has run the https://sqlite.org/ website since 2004. Althttpd strives for simplicity, security, and low resource usage.
As of 2022, the althttpd instance for sqlite.org answers about 500,000 HTTP requests per day (about 5 or 6 per second) delivering about 200GB of content per day (about 18 megabits/second) on a $40/month Linode. The load average on this machine normally stays around 0.5. About 10% of the HTTP requests are CGI to various Fossil source-code repositories.

详见 Althttpd: The Althttpd Webserver.
Althttpd 源码只有一个 c 文件,我们将其改造,然后将 BPC 最终转译出来的.c 和 althttpd.c 编译在一起,于是一个全新的 web server 诞生了!
如果编译时再加上 --static 选项,那么最终交付时,就一个可执行文件,包含了 web server + php 逻辑 + js/css/image 等静态资源, 非常便捷!
BPC Playground
BPC 官网 https://bpc.dev Try it Online ( BPC Playground ) 已经支持将合适的项目编译成 althttpd, 感兴趣的可以试一试!

bpc, althttpd, PHP, mod_bpc

vitovan   
下一步就是 WebAssembly 了吧。
您需要登录后才可以回帖 登录 | 立即注册

返回顶部