PHPacker 使您能够将任何 PHP 脚本或 PHAR 打包成一个独立的、跨平台的可执行文件。它处理了将 PHP 与应用程序捆绑在一起的所有复杂性,使分发变得简单而轻松。
composer require phpacker/phpacker --dev
新建一个 PHP 脚本文件 app.php
:
<?php
/**
* @desc app.php 描述信息
* @author Tinywan(ShaoBo Wan)
*/
declare(strict_types=);
echo 'Hello 开源技术小栈' . PHP_EOL;
使用单个命令从 PHP 脚本构建独立的可执行文件:
vendor/bin/phpacker build --src=./app.php
You're using the latest version: phpacker/php-bin:0.3.4
┌ Select platform ─────────────────────────────────────────────┐
│ › ● Mac │
│ ○ Linux │
│ ○ Windows │
│ ○ all │
└──────────────────────────────────────────────────────────────┘
mac - arm ·············································· ✅
mac - x64 ·············································· ✅
linux - arm ············································ ✅
linux - x64 ············································ ✅
windows - x64 ·········································· ✅
查看打包结果:
cd build
linux mac windows
Linux
build/linux/linux-arm
Hello 开源技术小栈
Windows
build/windows/windows-x64.exe
Hello 开源技术小栈
当您不提供任何输入时,系统会提示您设置基本信息。您也可以将这些作为参数传递给 build 命令。
# Build for specific platform and architecture
phpackerbuildmacarm--src=./app.phar
# Build for all supported platforms
phpackerbuildall--src=./app.phar
# Build with custom output directory
phpackerbuild--src=./app.phar--dest=./custom-build-path
# Build with a specific PHP configuration file
phpackerbuild--src=./app.phar--ini=./custom-php.ini
# Prompt INI definitions interactively
phpackerbuild--src=./app.phar--ini
# Build with with php version
phpackerbuild--src=./app.phar--php=8.3
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有