PHPackages                             inphp/service - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. inphp/service

ActiveLibrary[HTTP &amp; Networking](/categories/http)

inphp/service
=============

PHP应用服务

0.9.2(5y ago)018MITPHPPHP ^7.2

Since Dec 1Pushed 5y ago1 watchersCompare

[ Source](https://github.com/lulanyin/inphp-service)[ Packagist](https://packagist.org/packages/inphp/service)[ RSS](/packages/inphp-service/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

PHP 应用服务
========

[](#php-应用服务)

注：开发阶段，需求还在构思中，未形成发布版，仅供参考！

### 配置暂定

[](#配置暂定)

```
return [
    //http 配置
    'http'  => [
        //server 类型(仅在swoole http server有效)
        'sock_type'      => defined('SWOOLE_SOCK_TCP') ? SWOOLE_SOCK_TCP : null,
        //绑定IP(仅在swoole http server有效)
        'ip'        => '0.0.0.0',
        //绑定端口(仅在swoole http server有效)
        'port'      => 1990,
        //服务配置(仅在swoole http server有效)
        'settings'  => [
            //swoole\http\server 的配置，已默认一些配置，可重写
            //PID文件保存位置，文件夹必须存在
            'pid_file'              => RUNTIME.'/http_service.pid',
            //worker 数量，一般按CPU核心数量 * 2
            'worker_num'            => 2,
            //最大请求数量，按需，不可超过系统设置
            'max_request'           => 128,
            //最大连接数量
            'max_connection'        => 256,
            //日志文件，文件夹必须存在
            'log_file'              => RUNTIME.'/http_service.log',
            //默认异步进程数量
            'task_worker_num'       => 2,
            'package_max_length'    => 8092,
            'upload_tmp_dir'        => RUNTIME.'/upload',
            //默认静态文件目录，文件夹必须存在，一般使用nginx代理完成静态文件访问
            'document_root'         => ROOT.'/public',
            //文件上传保存文件夹
            'upload_dir'            => ROOT.'/public/attachment'
        ],
        //是否开启热更新
        'hot_update'   => [
            //是否打开
            'enable'    => true,
            //热更新监听的文件夹
            'listen_dir'=> [
                APP_PATH."/http",
                VIEW
            ],
            //热更新版本缓存文件
            'version_file' => RUNTIME."/http_version.txt",
            //热更新间隔时间
            'seconds'   => 10
        ],
        //http入口
        'home'      => 'Inphp\ServiceSimple\app\http\\',
        //视图文件
        'view'      => VIEW,
        //视图文件后缀，请勿带 .
        'view_suffix' => 'html',
        //视图是否允许执行PHP
        'view_php'  => false,
        //路由
        'router'    => [
            //默认访问位置 {home}\{router.default}，值对应下方 list 的 key
            'default'   => 'public',
            //列表， key 值是地址路径， value 是文件夹名称， 位于 {home} 下级文件夹
            'list'      => [
                //网站默认访问位置
                'public'    => 'web',
                //后台
                'adm@xyz'   => 'admin',
                //API接口
                'api'       => 'api'
            ],
            //自定义响应数据类型，默认是以控制器为准，其次是视图，然后可自定义为 json 或 application/json
            //JSON统一格式 { error : 0, message : 'success', data : '您响应的数据' }
            'response_content_type' => [
                //API接口的响应数据类型是JSON
                'api'   => 'application/json'
            ],
            //可配置独立域名，key 对应上方 list 的 value，值是独立域名，会自动识别使用该域名访问时，默认的访问入口。
            'domains'   => [
                'api'   => 'api-service.inphp.in'
            ],
            //跨域
            'access_origin' => [
                //API支持任何跨域
                'api'   => '*'
            ]
        ],
        //中间键 或 回调
        'middleware'    => [
            //------------------------------ 服务
            //服务启动前
            'before_start'  => [

            ],
            //服务启动(仅在swoole http server有效)
            'on_start'         => [],
            //子进程启动(仅在swoole http server有效)
            'on_worker_start'  => [],
            //------------------------------ 请求部分
            //接收到请求
            'on_request'    => [
                //继承
                \Inphp\ServiceSimple\app\middleware\middle::class,
                //直接函数
                function(){
                    echo 'fun before_start'.PHP_EOL;
                },
                //静态方法
                [\Inphp\ServiceSimple\app\middleware\middle::class, 'static_process']
            ],
            //路由处理
            'on_router'     => [],
            //控制器已初始化，但未执行前
            'before_execute'=> [],
            //控制器已执行，未响应前
            'before_send'   => [],
            //----------------------------- 异步投递
            //投递异步任务(仅在swoole http server有效)
            'on_task'       => [],
            //异步任务执行完成(仅在swoole http server有效)
            'on_finish'     => []
        ],
        //cookie
        'cookie'    => [
            //cookie加密字符，默认值是123456，使用sha1
            'hash_key'  => '1v3r5a',
            //位置
            'path'      => '/',
            //https
            'secure'    => false,
            //http only
            'http_only' => true,
            //共享域名 xx.a.com  请勿添加 http:// 或 https:// 开头
            'domains'   => []
        ],
        //session， 该配置仅对 swoole http server 有效，因为swoole无法像PHP-FPM一样使用 $_SESSION
        'session'   => [
            //所用驱动，默认使用 cache 系统，如果使用其它，请填写 middleware，并实现它
            'driver'    => 'cache',
            //保存位置
            'path'      => RUNTIME.'/session',
            //使用中间键处理
            'middleware'=> [
                'get'   => null,
                'set'   => null,
                'remove'  => null
            ]
        ]
    ],
    //swoole websocket 配置
    'ws'    => [
        //server 类型
        'sock_type'      => defined('SWOOLE_SOCK_TCP') ? SWOOLE_SOCK_TCP : null,
        //绑定IP
        'ip'        => '0.0.0.0',
        //绑定端口
        'port'      => 1991,
        //服务配置(仅在swoole http server有效)
        'settings'  => [
            //swoole\http\server 的配置，已默认一些配置，可重写
            //PID文件保存位置，文件夹必须存在
            'pid_file'              => RUNTIME.'/ws_service.pid',
            //worker 数量，一般按CPU核心数量 * 2
            'worker_num'            => 2,
            //最大请求数量，按需，不可超过系统设置
            'max_request'           => 128,
            //最大连接数量
            'max_connection'        => 256,
            //日志文件，文件夹必须存在
            'log_file'              => RUNTIME.'/ws_service.log',
            //默认异步进程数量
            'task_worker_num'       => 2,
            'package_max_length'    => 8092
        ],
        //是否开启热更新
        'hot_update'   => [
            //是否打开
            'enable'    => true,
            //热更新监听的文件夹
            'listen_dir'=> [
                APP_PATH."/ws"
            ],
            //热更新版本缓存文件
            'version_file' => RUNTIME."/ws_version.txt",
            //热更新间隔时间
            'seconds'   => 10
        ],
        //ws入口
        'home'      => 'Inphp\ServiceSimple\app\ws\\',
        //路由
        'router'    => [
            //默认访问位置 {home}\{router.default}，值对应下方 list 的 key
            'default'   => 'public',
            //列表， key 值是地址路径， value 是文件夹名称， 位于 {home} 下级文件夹
            'list'      => [
                //默认消息接收
                'public'    => 'web',
            ]
        ],
        //中间键 或 回调
        'middleware'    => [
            //------------------------------ 服务
            //服务启动前
            'before_start'  => [],
            //服务启动(仅在swoole http server有效)
            'on_start'         => [],
            //子进程启动(仅在swoole http server有效)
            'on_worker_start'  => [],
            //------------------------------ 消息部分
            //新连接
            'on_open'       => [],
            //关闭
            'on_close'      => [],
            //收到客户端消息
            'on_message'    => [],
            //事件路由处理
            'on_router'     => [],
            //------------------------------ 控制器
            //控制器已初始化，但未执行前
            'before_execute'=> [],
            //向客户端发送消息之前（注意，这里指的是执行 $server->send()）
            'before_send'   => [],
            //----------------------------- 异步投递
            //投递异步任务(仅在swoole http server有效)
            'on_task'       => [],
            //异步任务执行完成(仅在swoole http server有效)
            'on_finish'     => [],
            //----------------------------- 未知数据
            'unknow_data'   => []
        ]
    ],
    //客户端临时数据缓存，HTTP，WS共用，http的session默认使用这里
    'cache'    => [
        //缓存驱动，默认使用文件
        'driver'    => 'file',
        //缓存文件夹
        'path'      => RUNTIME.'/client',
        //使用中间键处理
        'middleware'=> [
            //获取
            'get'   => null,
            //设置
            'set'   => null,
            //移除
            'remove'=> null,
            //清除所有
            'clean' => null
        ]
    ]
];
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~31 days

Total

3

Last Release

1931d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e7ba8f963b6d1a5d3ab8596777a2397367b19b013111e99f640e564045240178?d=identicon)[lanyin](/maintainers/lanyin)

---

Top Contributors

[![lulanyin](https://avatars.githubusercontent.com/u/5426155?v=4)](https://github.com/lulanyin "lulanyin (5 commits)")

---

Tags

php-httpphp-websocketphp http servicephp websocket service

### Embed Badge

![Health badge](/badges/inphp-service/health.svg)

```
[![Health](https://phpackages.com/badges/inphp-service/health.svg)](https://phpackages.com/packages/inphp-service)
```

###  Alternatives

[php-http/httplug-bundle

Symfony integration for HTTPlug

38921.0M54](/packages/php-http-httplug-bundle)[illuminate/http

The Illuminate Http package.

11936.0M5.1k](/packages/illuminate-http)[php-http/laravel-httplug

Laravel package to integrate the Httplug generic HTTP client into Laravel

12110.1k](/packages/php-http-laravel-httplug)[yzh52521/easyhttp

EasyHttp 是一个轻量级、语义化、对IDE友好的HTTP客户端，支持常见的HTTP请求、异步请求和并发请求，让你可以快速地使用 HTTP 请求与其他 Web 应用进行通信。

429.3k3](/packages/yzh52521-easyhttp)[shieldon/psr-http

HTTP implementation for PSR standard.

1826.3k4](/packages/shieldon-psr-http)[gouguoyin/easyhttp

EasyHttp 是一个轻量级、语义化、对IDE友好的HTTP客户端，支持常见的HTTP请求、异步请求和并发请求，让你可以快速地使用 HTTP 请求与其他 Web 应用进行通信。

351.1k](/packages/gouguoyin-easyhttp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
