PHPackages                             imiphp/openai-chatgpt - 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. [Framework](/categories/framework)
4. /
5. imiphp/openai-chatgpt

ActiveProject[Framework](/categories/framework)

imiphp/openai-chatgpt
=====================

这是一个在 imi 框架接入 OpenAI ChatGPT 的 Demo 项目。https://imiphp.com

v1.0.2(3y ago)13491PHPPHP &gt;=7.4

Since Mar 9Pushed 3y ago2 watchersCompare

[ Source](https://github.com/imiphp/imi-openai-chatgpt)[ Packagist](https://packagist.org/packages/imiphp/openai-chatgpt)[ RSS](/packages/imiphp-openai-chatgpt/feed)WikiDiscussions master Synced 1mo ago

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

说明
==

[](#说明)

这是一个在 imi 框架接入 OpenAI ChatGPT 的 Demo 项目。

OpenAI 的接口使用了 html5 新加入的 `event-stream` 技术，imi 编写的接口同样采用了该技术，可以实现实时返回 AI 回复的内容。

建议使用 Swoole 最新版本！

imi 框架：

imi 文档：

OpenAI：

> 如何注册请自行搜索解决。

安装
--

[](#安装)

创建项目：`composer create-project imiphp/openai-chatgpt`

配置
--

[](#配置)

复制 `.env.tpl` 为 `.env`。

修改 `.env` 配置即可。

运行
--

[](#运行)

`vendor/bin/imi-swoole swoole/start`

访问测试
----

[](#访问测试)

控制器：`Module/Test/ApiController/IndexController.php`

页面模版：`Module/Test/template/index/index.html`

生产环境
----

[](#生产环境)

**关闭热更新：**`config/beans.php` 中 `hotUpdate.status` 设为 `false`

代码质量
----

[](#代码质量)

### 格式化代码

[](#格式化代码)

内置 `php-cs-fixer`，统一代码风格。

配置文件 `.php-cs-fixer.php`，可根据自己实际需要进行配置，文档：

**格式化项目：** `./vendor/bin/php-cs-fixer fix`

**格式化指定文件：** `./vendor/bin/php-cs-fixer fix test.php`

### 代码静态分析

[](#代码静态分析)

内置 `phpstan`，可规范代码，排查出一些隐藏问题。

配置文件 `phpstan.neon`，可根据自己实际需要进行配置，文档：

**分析项目：** `./vendor/bin/phpstan`

**分析指定文件：** `./vendor/bin/phpstan test.php`

### 测试用例

[](#测试用例)

内置 `phpunit`，可以实现自动化测试。

**文档：**

**测试用例 demo：**`tests/Module/Test/TestServiceTest.php`

**运行测试用例：**`composer test`

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

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 ~1 days

Total

3

Last Release

1155d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f917bb42280d114c53cebadc2942a13ee03abe14971089f88895e266d637169?d=identicon)[Yurunsoft](/maintainers/Yurunsoft)

---

Top Contributors

[![Yurunsoft](https://avatars.githubusercontent.com/u/20104656?v=4)](https://github.com/Yurunsoft "Yurunsoft (6 commits)")

---

Tags

chatgptopenaiphpswoole

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/imiphp-openai-chatgpt/health.svg)

```
[![Health](https://phpackages.com/badges/imiphp-openai-chatgpt/health.svg)](https://phpackages.com/packages/imiphp-openai-chatgpt)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M190](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M591](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M120](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91245.3M584](/packages/laravel-pail)

PHPackages © 2026

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