开源PHP应用服务器:采用Go编写、支持Early Hints
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">你<span style="color: black;">是不是</span>曾梦想过</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">一个现代化的 PHP 应用服务器</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">能够突破传统的<span style="color: black;">捆绑</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">赋予你的项<span style="color: black;">日前</span>所未有的性能和灵活性?</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">那样</span>,</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">FrankenPHP 正是你梦寐以求的<span style="color: black;">处理</span><span style="color: black;">方法</span>!</span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-axegupay5k/b5d93ed16c1e4b9f8ee13e396a5b56ef~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728297820&x-signature=r3ADoO0cGEPCA9avZm5tszk%2FESo%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">FrankenPHP 是一个基于 Caddy Web 服务器构建的现代 PHP 应用服务器,</span><strong style="color: blue;"><span style="color: black;">采用 Go 和 C 编写</span></strong><span style="color: black;">。它依赖 Go 的标志性功能:goroutines。</span></span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-6w9my0ksvp/8533eb5f988a49f7acaae5a941f0cb2a~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728297820&x-signature=9Y1r6HFsfcIeSFuGzJMH8nMSfAs%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">FrankenPHP 特性<span style="color: black;">包含</span>:</span></span></p><span style="color: black;"><strong style="color: blue;"><span style="color: black;">Early Hints(提前提示)</span></strong><span style="color: black;">:这是 Web 平台的一个全新特性,<span style="color: black;">能够</span><span style="color: black;">经过</span>提前 30% 的时间加载网站。FrankenPHP 是<span style="color: black;">独一</span>支持提前提示的 PHP SAPI</span></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">Worker 模式</span></strong><span style="color: black;">:一次<span style="color: black;">起步</span>应用程序并保持其在内存中</span></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">实时功能</span></strong><span style="color: black;">:内置的 Mercure 中心。从 PHP 应用程序发送事件到所有连接的浏览器,它们立即<span style="color: black;">做为</span> JavaScript 事件接收负载</span></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">可伸缩</span></strong><span style="color: black;">:与 PHP 8.2+、大<span style="color: black;">都数</span> PHP 扩展和所有 Caddy 模块兼容</span></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">易于<span style="color: black;">安排</span></span></strong><span style="color: black;">:<span style="color: black;">做为</span> Docker 镜像的云原生应用交付,兼容 Kubernetes 和所有现代云平台。<span style="color: black;">亦</span><span style="color: black;">能够</span>将您的 PHP 应用程序打包为独立的、自执行的静态二进制文件。</span></span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">自动 HTTPS、HTTP/2 和 HTTP/3 支持等</span></strong><span style="color: black;">。</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">FrankenPHP <span style="color: black;">运用</span>演示</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">一条命令运行所有</span></strong></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">只需<span style="color: black;">运用</span>一条命令<span style="color: black;">就可</span><span style="color: black;">起步</span>并运行一个生产级别的 PHP 服务器。</span></span></p><span style="color: black;"># Dockerdocker run -v $PWD:/app/public -p 443:443 \ dunglas/frankenphp</span>
<span style="color: black;"># 静态二进制文件./frankenphp php-server</span>
<span style="color: black;"># 命令行脚本./frankenphp php-cli /path/to/your/script.php</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">配置非常简单</span></strong></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">只需五行配置,由 Caddy <span style="color: black;">供给</span>支持。</span></span></p><span style="color: black;">{</span>
<span style="color: black;"># 启用 FrankenPHP</span>
<span style="color: black;">frankenphp</span>
<span style="color: black;">order</span> <span style="color: black;">php_server before file_server</span>
<span style="color: black;">}</span>
<span style="color: black;">localhost</span> <span style="color: black;">{</span>
<span style="color: black;"> # 启用压缩(可选)</span>
<span style="color: black;">encode</span> <span style="color: black;">zstd br gzip</span>
<span style="color: black;"> # 执行当前目录中的PHP文件并<span style="color: black;">供给</span>资产</span>
<span style="color: black;">php_server</span>
<span style="color: black;">}</span>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">FrankenPHP 亮点介绍</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">Early Hints</span></strong><span style="color: black;">:FrankenPHP 原生支持 103 Early Hints 状态码,<span style="color: black;">能够</span>将网页的加载时间缩短 30%。在普通模式和 worker 模式下都支持。</span></span></p><?<span style="color: black;">php
<span style="color: black;">header</span>(<span style="color: black;"><span style="color: black;">Link: </style.css>; rel=preload; as=style</span></span>)</span>;headers_send(<span style="color: black;">103</span>);
<span style="color: black;">// your slow algorithms and SQL queries</span>
echo <<<<span style="color: black;">HTML</span>
<!DOCTYPE html>
<title>Hello FrankenPHP</title>
<link rel=<span style="color: black;">"stylesheet"</span> href=<span style="color: black;">"style.css"</span>>HTML;<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Early Hints 是一种 HTTP 状态代码 (</span><span style="color: black;"><span style="color: black;">103 Early Hints</span></span><span style="color: black;">),用于在<span style="color: black;">最后</span>响应之前发送初步 HTTP 响应。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">这般</span>,服务器可在服务器忙于生成<span style="color: black;">重点</span>资源时,向浏览器发送关于网页可能<span style="color: black;">运用</span>的关键子资源(例如网页的样式表、关键 JavaScript)或源的提示。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在等待<span style="color: black;">重点</span>资源<span style="color: black;">时期</span>,浏览器<span style="color: black;">能够</span><span style="color: black;">运用</span>这些提示来预热连接并请求子资源。<span style="color: black;">亦</span><span style="color: black;">便是</span>说,Early Hints <span style="color: black;">经过</span>提前执行<span style="color: black;">有些</span>工作来<span style="color: black;">帮忙</span>浏览器充分利用此类 “服务器思考时间”,从而加快网页加载速度。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">Worker 模式</span></strong><span style="color: black;">:<span style="color: black;">起步</span>应用程序并将其驻留在内存中,FrankenPHP 将在几毫秒内处理传入的请求。</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">实时功能</span></strong><span style="color: black;">:FrankenPHP 配有内置 Mercure Hub,Mercure <span style="color: black;">准许</span>将事件实时推送到所有连接的设备,它们将立即收到 JavaScript 事件。无需 JS 库或 SDK。</span></span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/tos-cn-i-6w9my0ksvp/e2901508fe1e48aa952c2367f52ca8f8~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728297820&x-signature=Rjdeb5gUs1JWB%2FRqIsMn%2BgzHvbg%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">FrankenPHP 可与任何 PHP 应用<span style="color: black;">协同</span><span style="color: black;">运用</span>,并且<span style="color: black;">因为</span>其与 Worker 模式的官方集成,使得 Laravel 和 Symfony 项目比以往任何时候都快。</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">FrankenPHP 还<span style="color: black;">能够</span><span style="color: black;">做为</span>独立的 Go 库<span style="color: black;">运用</span>,<span style="color: black;">经过</span> net/http 在任何应用程序中嵌入 PHP。</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">详情查看:</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">https://github.com/dunglas/frankenphp</span></span></p>
太棒了、厉害、为你打call、点赞、非常精彩等。
页:
[1]