crazywhalecc / cli-helper
0.1.0
2022-06-04 06:16 UTC
Requires
- php: >= 7.2
- symfony/console: ^4 || ^5 || ^6
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-13 17:00:07 UTC
README
一个简单的PHP CLI助手。
基本用法
您可以下载这个辅助程序的打包可执行phar文件。
wget https://github.com/crazywhalecc/php-cli-helper/releases/download/0.1.0/cli-helper
chmod +x cli-helper
# Run it!
./cli-helper
将项目打包为单个可执行文件(需要安装PHP)
- 将
cli-helper
移动到PATH
# If you don't want to move it, remember your download path and directly execute it with its path. # If you are not root, remember using `sudo`. mv ./cli-helper /usr/local/bin/cli-helper
- 切换到要打包的项目目录,例如
/home/ubuntu/your-project
,并清理您的开发依赖项。
cd /home/ubuntu/your-project
composer update --no-dev
- 运行cli-helper,打包当前目录。
注意:此命令将询问您目标phar路径、入口文件名等。
cli-helper pack . app.phar
- 制作phar可执行文件
# add X permission chmod +x /tmp/app.phar # remove phar suffix, like a binary executable mv /tmp/app.phar /tmp/your-app-name # You can use it any way you like, for example, move to system PATH to execute it directly cd /tmp ./your-app-name mv your-app-name /usr/local/bin/ your-app-name
使用PHP制作独立二进制可执行文件(支持多种架构)
准备通过以上步骤打包的phar文件,假设您的phar名称为your-app.phar
。
# Download micro builds from `static-php-cli` project, remember check the latest PHP version from `https://dl.zhamao.xin/php-bin/file/` ! # You can change `x86_64` to `aarch64`, `armv7l`。 wget https://dl.zhamao.xin/php-bin/file/micro-8.0.19-x86_64.tar.gz tar -zxvf micro-*.tar.gz # Combine micro and your phar files cat ./micro your-app.phar > your-app-standalone chmod +x your-app-standalone # Then just execute it anywhere, even your another machine have no php environment! ./your-app-standalone
注意:此项目是static-php-cli的补充,更多详情请查看此链接。