uniondrug / phar
There is no license information available for the latest version (2.0.2) of this package.
builder PHAR package and start with swoole
2.0.2
2022-04-24 03:02 UTC
Requires
- guzzlehttp/guzzle: ^6.3
This package is auto-updated.
Last update: 2026-05-24 14:35:57 UTC
README
基于
uniondrug/sketch模板构建的项目, 可平滑切换到PHAR+Swoole运行模式。
- 安装依赖 - 在项目添加
uniondrug/phar依赖 - 添加入口 - 让项目支持
Command入口 - 项目打包 - 将项目打成
PHAR包 - 启动项目 - 以
PHAR方式启动项目 - 退出服务
- 项目部署 - 在
development、testing、release、production环境下的部署规范 - 注意事项 - 构建PHAR包时注意事项
- 项目名称与版本
- 启动IP与端口
- 服务参数
安装依赖
请在项目根目录下的
composer.json文件加添加uniondrug/phar扩展;效果如下
{
...
"require" : {
...
"uniondrug/console" : "^2.2",
"uniondrug/phar" : "^1.0"
},
...
}
添加入口
创建
app/Commands/PharCommand.php文件, 完整代码如下
<?php /** * @author wsfuyibing <websearch@163.com> * @date 2019-01-24 */ namespace App\Commands; /** * 构建PHAR入口 * @package App\Commands */ class PharCommand extends \Uniondrug\Phar\Commands\PharCommand { }
项目打包
将项目构建成
PHAR包
- 语法
php console phar -h
- 示例
php console phar php console phar -e production php console phar -e production --tag version php console phar -e production --tag version --name package
启动项目
- 语法
php package-version.phar start -h
- 示例
php package-version.phar start -h php package-version.phar start -e production php package-version.phar start -e production -d php package-version.phar start -e production -d --consul-register 127.0.0.1:8500 php package-version.phar start -e production --log-stdout
退出服务
- 语法
php package-version.phar stop -h
- 示例
php package-version.phar stop -l php package-version.phar stop -l --kill php package-version.phar stop -l --force-kill