基于
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