Download the PHP package dleno/hyperf-diy without Composer

On this page you can find all versions of the php package dleno/hyperf-diy. 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 hyperf-diy

dleno/hyperf-diy

dleno/hyperf-diy 是基于 Hyperf 3.2 和 dleno/common-core 的业务项目脚手架。它不是一个纯净 Hyperf 空项目,而是预置了 Dleno 项目常用的 HTTP、WebSocket、AMQP、AsyncQueue、Crontab、Model 分表、分布式锁、接口签名/加密、日志和测试示例。

项目定位:

环境要求

启用 WebSocket 时必须使用 SWOOLE_BASE 模式。本项目 config/autoload/server.php 默认已经设置为 SWOOLE_BASE。

创建项目

如果是 clone 源码,或使用 composer create-project --no-install 创建项目,再执行依赖安装:

本项目使用 dleno/hyperf-env-multi 管理环境配置。创建项目后会尝试复制 .env.local.example 到 .env.local。加载顺序固定为:先加载 .env,再根据 APP_ENV 加载 .env.<APP_ENV>;环境文件中的同名变量以后者为准。例如 APP_ENV=local 时,.env.local 会覆盖 .env 中的同名配置。common-core 会在自己的 ConfigProvider 读取 env() 前显式调用 EnvLoader::load(BASE_PATH),因此 ENABLE_HTTP / ENABLE_WS 等早期配置也会读取到环境覆盖后的值。实际部署时请按环境准备 .env / .env.<APP_ENV>,不要把生产密钥、数据库密码、RSA 私钥提交到仓库。

快速启动

最小 HTTP 启动配置:

启动服务:

健康检查:

返回空字符串且 HTTP 200 表示 HTTP server 正常。

目录结构

common-core 接入点

本项目依赖 dleno/common-core,并在 config/autoload/dependencies.php 中完成关键绑定:

其中:

异常处理器追加示例:

公共前置 handler 放到 httpCommonHandlers / wsCommonHandlers,会插入到 common-core 的 CommonExceptionHandler 之后,适合回滚、审计、上下文清理等不中断传播的处理;业务输出类 handler 放到 httpBeforeDefault / wsBeforeDefault,会插入到 common-core 的兜底 DefaultExceptionHandler 之前。不要把业务 handler 追加在默认链之后,否则异常可能已经被兜底 handler 截断。

HTTP 示例

入口示例:

能力说明:

示例请求:

实际路径会受 ROUTE_PREFIX、ROUTE_SUFFIX 和 AutoController 路由规则影响。

组件与配置示例

组件示例:

配置常量示例:

这些文件只是业务项目的起始示例,不会被 common-core 强制依赖。实际项目可以保留命名风格,也可以按业务模块拆分。

WebSocket 示例

相关目录:

启用配置:

注意:

默认绑定策略:

维度设计原则:

WS 路由:

WS 业务消息示例:

队列与进程

AsyncQueue

配置:config/autoload/async_queue.php

示例(静态队列 + 动态队列两套,目录结构与 common-core/examples/AsyncQueue 一致):

说明:

AMQP

配置:config/autoload/amqp.php

示例(三种调用方式分别成对,目录结构与 common-core/examples/Amqp 一致):

启用:

说明:

依赖版本快照(2026-10-25)

本次已正常 Composer 更新全部依赖。直接依赖以当前PHP8.4/Swoole6.2可用的最新稳定版为下限,Hyperf保持3.2系列;composer outdated --direct 为空。

依赖 已安装版本
dleno/common-core 3.2.5
hyperf/framework、crontab、devtool、testing、ide-helper 3.2.0
hyperf/websocket-server 3.2.1
friendsofphp/php-cs-fixer 3.95.27
mockery/mockery 1.6.15
phpstan/phpstan 2.3.2
squizlabs/php_codesniffer 4.0.4
swoole/ide-helper 6.2.3

PHPStan从1.x升到2.x、PHP_CodeSniffer从3.x升到4.x;现有项目静态分析配置、PHP语法、完整测试和路由加载已经验证,无需增加兼容补丁。间接依赖按上游支持的约束同步更新,不手动修改vendor。

common-core 3.2.5 接入

Crontab / Process

Crontab 配置:

相关文件:

Crontab 调度进程由 common-core ConfigProvider 按 ENABLE_CRONTAB 自动注册;config/autoload/processes.php 只用于追加业务自定义 Process,不要重复添加 Crontab 调度进程。

示例里的自定义 Process / Crontab 默认关闭;Crontab 示例保留 ENABLE_CRONTAB 前置门禁,业务使用时应先确认不会产生重复消费、重复任务或本地调试副作用。

Model 与分表

相关文件:

能力:

测试覆盖:

该测试会创建和删除测试表,运行前请确认连接的是本地测试数据库。

接口签名与加密

配置:config/autoload/app.php

关键配置:

注意:

日志与 DingTalk 告警

日志配置入口:

异常输出会读取 dingtalk.trace 指定的机器人配置;未配置、未启用或 token/secret 为空时不会发送通知。生产启用前应准备独立机器人密钥,并确认 Redis 可用,因为 DingTalk 发送频率限制使用 Redis pool。

重要环境变量

基础:

Swoole:

HTTP / API:

WebSocket:

数据库 / Redis / AMQP:

RPC / 服务发现:

DingTalk:

测试与静态分析

运行测试:

按用例过滤:

静态分析:

代码格式化:

测试注意:

Docker

项目包含:

可按本地环境使用容器启动依赖。不同团队的本地 Docker 编排可能不同,使用前请确认 .env.local 中 MySQL / Redis / RabbitMQ 主机名和密码与容器一致。

.dockerignore 会排除 .env.local(本地凭据)和本地 composer.lock(项目不提交锁文件,镜像内按 composer.json 重新解析)。生产凭据请通过运行时环境变量或 Secret 注入。

与 common-core 的关系

hyperf-diy 负责“业务项目模板和接入示例”,common-core 负责“公共核心能力”。推荐边界:

发布与升级 common-core

查看当前 common-core 版本:

升级 common-core:

升级后建议执行:

从 3.1 升级到 3.2(Hyperf 3.2 / PHP 8.4 / Swoole 6.2)时,本地残留的 3.1 composer.lock 与新约束不兼容,需重新解析:

业务侧配置变更(logger / cache 结构、AsyncQueue 等)见 dleno/common-core README 的「从 3.1 升级」。

安全提示


All versions of hyperf-diy with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
ext-swoole Version >=6.2
ext-json Version *
hyperf/framework Version ~3.2.0
hyperf/crontab Version ~3.2.0
hyperf/websocket-server Version ~3.2.0
dleno/common-core Version ~3.2.0
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 dleno/hyperf-diy contains the following files

Loading the files please wait ...