跨平台支持

TypePHP 目标 Windows / Linux / macOS 三大桌面平台,通过 Platform 抽象隔离系统差异(编译器名、目标扩展名、PHP embed 库查找等)。

Sources: src/Translator.php · src/Platform/

平台抽象

PlatformFactory::create() 按 OS 返回具体 Platform 对象(Windows / Linux / macOS)。detectPlatform()Translator 构造时调用,得到平台名 + 后端名(如 Windows + MSVC)。

Sources: src/Translator.php

各平台要点

平台默认后端链接产物特殊点
LinuxGCC/ClangELF 可执行 / .so推荐 Ubuntu 22.04,需 libphp.so
macOSClangMach-O / .dylibstrip 可选
WindowsMSVCPE .exe / .dll需 Windows SDK + php8ts.lib;资源文件编译

Windows 分支会额外 detectPhpLibs() 探测 embed 与 core 的 .lib,并把 isZts、SDK 路径注入 Windows 对象。

Sources: src/Translator.php · README.md

Windows 资源文件

bin 模式在 Windows 下编译 .rc(图标、版本信息、UAC 等,由 project.ymlresource 配置),生成的 .resbuild() 链接时并入。资源文件生成见 Generator/ResourceFileGeneratorBuild/ResourceCompilationTrait

Sources: project.yml · src/Translator.php · src/Build/ResourceCompilationTrait.php

libphp.so 自动安装

Linux 缺 libphp.so 时,tpc.php 可交互式下载 PHP 源码并自动构建,详见 docs/LIBPHP_INSTALLER.md;安装器逻辑在 src/Installer/

Sources: README.md · src/Installer/

相关阅读