PHPackages                             uniondrug/phar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. uniondrug/phar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

uniondrug/phar
==============

builder PHAR package and start with swoole

2.0.2(4y ago)37.8k4PHP

Since Jan 8Pushed 4y ago6 watchersCompare

[ Source](https://github.com/uniondrug/phar)[ Packagist](https://packagist.org/packages/uniondrug/phar)[ RSS](/packages/uniondrug-phar/feed)WikiDiscussions development Synced 3d ago

READMEChangelog (10)Dependencies (1)Versions (68)Used By (4)

PHAR
====

[](#phar)

> 基于`uniondrug/sketch`模板构建的项目, 可平滑切换到`PHAR`+`Swoole`运行模式。

1. [安装依赖](#%E5%AE%89%E8%A3%85%E4%BE%9D%E8%B5%96) - 在项目添加`uniondrug/phar`依赖
2. [添加入口](#%E6%B7%BB%E5%8A%A0%E5%85%A5%E5%8F%A3) - 让项目支持`Command`入口
3. [项目打包](#%E9%A1%B9%E7%9B%AE%E6%89%93%E5%8C%85) - 将项目打成`PHAR`包
4. [启动项目](#%E5%90%AF%E5%8A%A8%E9%A1%B9%E7%9B%AE) - 以`PHAR`方式启动项目
5. [退出服务](#%E9%80%80%E5%87%BA%E6%9C%8D%E5%8A%A1)
6. [项目部署](./docs/deploy.md) - 在`development`、`testing`、`release`、`production`环境下的部署规范
7. [注意事项](#%E6%B3%A8%E5%86%8C%E4%BA%8B%E9%A1%B9) - 构建PHAR包时注意事项
    1. 项目名称与版本
    2. 启动IP与端口
    3. 服务参数

### 安装依赖

[](#安装依赖)

> 请在项目根目录下的`composer.json`文件加添加`uniondrug/phar`扩展；效果如下

```
{
    ...
    "require" : {
        ...
        "uniondrug/console" : "^2.2",
        "uniondrug/phar" : "^1.0"
    },
    ...
}

```

### 添加入口

[](#添加入口)

> 创建`app/Commands/PharCommand.php`文件, 完整代码如下

```
