# hyperf-template **Repository Path**: s-gaolei/hyperf-template ## Basic Information - **Project Name**: hyperf-template - **Description**: hyperf 初始化项目模板 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-09-02 - **Last Updated**: 2025-04-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: hyperf ## README # Hyperf 项目模板 ## 环境依赖 Hyperf对系统环境有一些要求,它只能在`Linux`和`Mac`环境下运行,但由于`Docker`虚拟化技术的发展,Docker for Windows也可以作为Windows下的运行环境。 Dockerfile的各种版本已经在[hyperf/hyperf-docker]中为您准备好了(https://github.com/hyperf/hyperf-docker)项目,或者直接基于已经构建的[hyperf/hyperf](https://hub.docker.com/r/hyperf/hyperf)要运行的映像。 当您不想使用Docker作为运行环境的基础时,您需要确保您的操作环境符合以下要求: - PHP >= 8.1 - Any of the following network engines - Swoole PHP extension >= 4.5,with `swoole.use_shortname` set to `Off` in your `php.ini` - Swow PHP extension (Beta) - JSON PHP extension - Pcntl PHP extension - OpenSSL PHP extension (If you need to use the HTTPS) - PDO PHP extension (If you need to use the MySQL Client) - Redis PHP extension (If you need to use the Redis Client) # 快速运行 ## 本地环境运行 > 当您确保运行环境满足上诉`环境依赖`的各项时,您可以直接在您的环境中运行本项目 运行服务之前请参照 `.env.example` 文件创建并编写 `.env` 文件 ```shell php ./bin/hyperf.php start ``` ## docker 运行 ### docker-compose - 运行服务 > 运行服务之前请参照 `.env.example` 文件创建并编写 `.env` 文件 ```shell docker-compose up [-d] [--build] ``` > - `-d` : 后台运行 > - `--build` : 构建运行,若不指定,将自动寻找历史构建的镜像并使用 - 关闭服务 > 关闭容器,并移除相关网络 ```shell docker-compose down ``` # 框架脚手架 - Model 生成模型文件 ```shell php bin/hyperf.php gen:model tableName ``` - Migration 生成数据迁移文件 ```shell php bin/hyperf.php gen:mirgation scriptName ``` - Controller 生成控制器文件 ```shell php bin/hyperf.php gen:controller controllerName ``` 更多框架使用的相关资料可参考 [官方文档](https://hyperf.wiki/3.0/)