PHPackages                             gnp/yaf\_swoole\_plug - 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. [API Development](/categories/api)
4. /
5. gnp/yaf\_swoole\_plug

ActiveLibrary[API Development](/categories/api)

gnp/yaf\_swoole\_plug
=====================

swoole\_web\_server结合yaf实现高效api接口

2191PHP

Since Jul 31Pushed 9y ago1 watchersCompare

[ Source](https://github.com/gnpok/yaf_swoole_plug)[ Packagist](https://packagist.org/packages/gnp/yaf_swoole_plug)[ RSS](/packages/gnp-yaf-swoole-plug/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

yaf结合swoole httpserver写的api接口
=============================

[](#yaf结合swoole-httpserver写的api接口)

为什么写这个
------

[](#为什么写这个)

参照了 [LinkedDestiny](https://github.com/LinkedDestiny/swoole-yaf) [xuebingwang](https://github.com/xuebingwang/xbw-swoole-yaf) ，觉得太裸露，就决定用composer形式来写，同时也是一种锻炼

程序我会在应用中进一步完善，同时希望大家给点意见

Requirement
-----------

[](#requirement)

- yaf扩展
- swoole扩展

如何使用
----

[](#如何使用)

### 1.生成yaf框架

[](#1生成yaf框架)

[生成yaf框架](https://github.com/laruence/yaf/tree/master/tools/cg)

### 2.使用composer安装

[](#2使用composer安装)

在yaf框架根目录下面使用命令行输入

```
$ composer require gnp/yaf_swoole_plug dev-master

```

然后更新composer

```
$ composer update

```

```
//修改yaf框架入口文件

define('APPLICATION_PATH', dirname(__FILE__));
require_once dirname(__FILE__).'/vendor/autoload.php';

if (PHP_SAPI === 'cli'){
    //传入swoole的配置
	$config = array();
   	Ysp\Entry::startServer($config);
}else{
    //这边是传统的apache或php-fpm模式
	$application = new Yaf_Application( APPLICATION_PATH . "/conf/application.ini");
	$application->bootstrap()->run();
}

//为了方便，我封装了get和post方法，存放在src/common/function.php
将代码拷贝出来，放入框架中去
```

启动服务

```
//进入yaf框架入口文件对应目录，在命令行模式下输入
php index.php

//打开浏览器，输入localhost:9501
hello world
```

3.与nginx结合
----------

[](#3与nginx结合)

[参考我另一个项目中的说明](https://github.com/gnpok/yafApi)

4.swoole的异步任务
-------------

[](#4swoole的异步任务)

[参考我另一个项目中的说明](https://github.com/gnpok/yafApi)

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9125224?v=4)[hodor](/maintainers/gnpok)[@gnpok](https://github.com/gnpok)

---

Top Contributors

[![gnpok](https://avatars.githubusercontent.com/u/9125224?v=4)](https://github.com/gnpok "gnpok (7 commits)")

### Embed Badge

![Health badge](/badges/gnp-yaf-swoole-plug/health.svg)

```
[![Health](https://phpackages.com/badges/gnp-yaf-swoole-plug/health.svg)](https://phpackages.com/packages/gnp-yaf-swoole-plug)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.5M7](/packages/exsyst-swagger)[lucasdotvin/laravel-soulbscription

A straightforward interface to handle subscriptions and features consumption.

709209.3k](/packages/lucasdotvin-laravel-soulbscription)[pimax/fb-messenger-php

Facebook Messenger Bot PHP API

313188.5k2](/packages/pimax-fb-messenger-php)

PHPackages © 2026

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