Download the PHP package yangweijie/think-runtime without Composer

On this page you can find all versions of the php package yangweijie/think-runtime. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package think-runtime

ThinkPHP Runtime 扩展包

高性能环境下运行的ThinkPHP Runtime扩展包,支持Swoole、RoadRunner、FrankenPHP等多种运行时环境。

特性

支持的运行时

运行时 描述 优先级 要求
Swoole 基于Swoole的高性能HTTP服务器 100 ext-swoole
FrankenPHP 现代PHP应用服务器,支持HTTP/2、HTTP/3 95 frankenphp 二进制文件
Workerman 高性能PHP socket服务器框架 93 workerman/workerman
ReactPHP 事件驱动的异步HTTP服务器 92 react/http, react/socket
RoadRunner 基于Go的高性能应用服务器 90 spiral/roadrunner
Bref AWS Lambda serverless运行时 85 bref/bref
Vercel Vercel serverless functions运行时 80 vercel/php

安装

要求

安装步骤

故障排除

1. 命令不可用

如果安装后没有看到runtime命令,请尝试以下解决方案:

2. ReactPHP 依赖问题

如果使用 ReactPHP 运行时遇到 Class "RingCentral\Psr7\Request" not found 错误:

3. Swoole 进程问题

如果 Swoole 运行时出现 Worker 进程退出:

快速开始

1. 配置

在ThinkPHP应用的config目录下创建runtime.php配置文件:

2. 启动服务器

3. 查看运行时信息

使用示例

基本使用

自定义适配器

配置说明

Swoole配置

FrankenPHP配置

ReactPHP配置

RoadRunner配置

RoadRunner配置

Workerman配置

Bref配置

Vercel配置

RoadRunner 运行指南

1. 安装依赖

2. 创建 RoadRunner 配置文件

在项目根目录创建 .rr.yaml 配置文件:

3. 创建 Worker 文件

在项目根目录创建 worker.php 文件:

4. 启动 RoadRunner 服务

5. 管理 RoadRunner 服务

6. 性能优化

可以通过调整 .rr.yaml 中的以下配置来优化性能:

运行时可用性要求

要让每个运行时在 php think runtime:info 中显示 "Available: Yes",需要满足以下条件:

Swoole Runtime

要求

安装步骤

配置: 在 php.ini 中添加:

FrankenPHP Runtime

要求

安装步骤

环境变量(可选):

Workerman Runtime

要求

安装步骤

ReactPHP Runtime

要求

安装步骤

Ripple Runtime

要求

安装步骤

RoadRunner Runtime

要求

安装步骤

Bref Runtime

要求

安装步骤

AWS Lambda 环境变量(自动设置):

Vercel Runtime

要求

安装步骤

Vercel 环境变量(自动设置):

故障排除

常见问题

  1. Swoole 显示 "Not Available"

  2. FrankenPHP 显示 "Not Available"

  3. Composer 包未找到

  4. 权限问题

命令行工具

runtime:start

启动运行时服务器

参数:

选项:

示例:

runtime:info

显示运行时环境信息

显示内容包括:

命令行工具改进

v1.3.0 重大优化

  1. 代码结构优化

    • 将RuntimeStartCommand中的if-else链重构为switch语句
    • 提高代码可读性和维护性
    • 更清晰的runtime处理逻辑
  2. 新runtime支持

    • 完整支持Bref、Vercel、Workerman runtime
    • 智能参数处理,根据runtime类型自动调整选项
    • 专门的serverless环境适配
  3. 参数处理优化

    • Workerman: --workers 自动转换为 count 参数
    • Bref/Vercel: 自动移除不适用的选项(host, port, workers, daemon)
    • FrankenPHP: --host--port 自动合并为 listen 参数
    • ReactPHP: 自动移除不支持的 workers 选项
    • RoadRunner: 自动移除不适用的网络选项
  4. 启动信息显示
    • 每个runtime都有专门的信息显示格式
    • Serverless runtime显示环境信息
    • 传统runtime显示网络和进程信息

测试

使用Pest测试框架:

开发规范

本项目严格遵循ThinkPHP8.0开发规范:

许可证

MIT License

性能优化建议

Swoole 性能优化

  1. 进程配置

  2. 静态文件优化

  3. 监控配置

ReactPHP 性能优化

  1. 连接管理

  2. 内存优化

Workerman 性能优化

  1. 进程配置

  2. 静态文件优化

  3. 监控配置

Bref/Vercel 性能优化

  1. Lambda/Serverless配置

  2. 冷启动优化

通用优化建议

  1. PHP配置

    • 启用OPcache
    • 设置合适的内存限制
    • 优化垃圾回收设置
  2. 系统配置

    • 调整系统文件描述符限制
    • 优化TCP内核参数
    • 使用SSD存储
  3. 应用优化
    • 使用数据库连接池
    • 实现缓存策略
    • 优化数据库查询

故障排除

常见问题

  1. Swoole扩展未安装

  2. ReactPHP依赖缺失

  3. 调试工具条时间累加

    • 已在v1.1.0版本修复
    • 自动重置全局状态和调试信息
  4. 端口被占用

  5. 权限问题

贡献

欢迎提交Issue和Pull Request!

贡献指南

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 打开 Pull Request

开发环境

更新日志

v1.3.0 (最新)

v1.2.0

v1.1.0

v1.0.0


All versions of think-runtime with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
nyholm/psr7 Version ^1.3
nyholm/psr7-server Version ^1.0
psr/http-message Version ^1.0|^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
topthink/framework Version ^8.0
topthink/think-orm Version 3.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yangweijie/think-runtime contains the following files

Loading the files please wait ....