Sign inSign up

swoft/swoft-echo-server

By swoft

•Updated over 7 years ago

Swoft echo server

Image
0

427

swoft/swoft-echo-server repository overview

    swoft ⁠

Latest Version Build Status Php Version Swoole Version Hiredis Version Swoft Doc Swoft License

⁠简介

基于 Swoole 原生协程,新时代PHP高性能协程框架,内置 HTTP 服务器,框架全协程实现,性能大大优于传统的 PHP-FPM 模式。

  • 基于 Swoole 扩展
  • 内置 HTTP 协程服务器
  • MVC 分层设计
  • 高性能路由
  • 全局容器注入
  • 灵活的中间件
  • 高性能 RPC
  • 别名机制
  • 事件机制
  • 国际化(i18n)
  • 参数验证器
  • RESTful支持
  • 服务治理熔断、降级、负载、注册与发现
  • 连接池 Mysql、Redis、RPC
  • 数据库 ORM
  • 协程、异步任务投递
  • 自定义用户进程
  • RPC、Redis、HTTP、Mysql 协程和同步阻塞客户端无缝切换
  • Inotify 自动 Reload
  • 强大的日志系统

⁠系统架构

    swoft ⁠

⁠文档

中文文档⁠

QQ交流群:548173319

⁠环境要求

  1. PHP 7.X
  2. Swoole 2.x⁠, 需开启协程和异步Redis
  3. Hiredis⁠
  4. Composer⁠
  5. Inotify⁠ (可选)

⁠安装

⁠手动安装

  • Clone 项目
  • 安装依赖 composer install

⁠Composer 安装

  • composer create-project swoft/swoft swoft dev-master

⁠Docker 安装

  • docker run -p 80:80 swoft/swoft

⁠配置

复制项目根目录的 .env.example 并命名为 .env

# Server
PFILE=/tmp/swoft.pid
PNAME=php-swoft
TCPABLE=true
CRONABLE=false
AUTO_RELOAD=true

# HTTP
HTTP_HOST=0.0.0.0
HTTP_PORT=80

# TCP
TCP_HOST=0.0.0.0
TCP_PORT=8099
TCP_PACKAGE_MAX_LENGTH=2048
TCP_OPEN_EOF_CHECK=false

# Crontab
CRONTAB_TASK_COUNT=1024
CRONTAB_TASK_QUEUE=2048

# Settings
WORKER_NUM=1
MAX_REQUEST=10000
DAEMONIZE=0
DISPATCH_MODE=2
LOG_FILE=@runtime/swoole.log
TASK_WORKER_NUM=1

⁠启动

帮助命令

[root@swoft bin]# php swoft -h
 ____                __ _
/ ___|_      _____  / _| |_
\___ \ \ /\ / / _ \| |_| __|
 ___) \ V  V / (_) |  _| |_
|____/ \_/\_/ \___/|_|  \__|

Usage:
  php swoft -h

Commands:
  entity  the group command list of database entity
  rpc     the group command list of rpc server
  server  the group command list of http-server

Options:
  -v,--version  show version
  -h,--help     show help

HTTP启动

是否同时启动RPC服务器取决于.env文件配置

// 启动服务,根据 .env 配置决定是否是守护进程
php bin/swoft start

// 守护进程启动,覆盖 .env 守护进程(DAEMONIZE)的配置
php bin/swoft start -d

// 重启
php bin/swoft restart

// 重新加载
php bin/swoft reload

// 关闭服务
php bin/swoft stop

RPC启动

启动独立的RPC服务器

// 启动服务,根据 .env 配置决定是否是守护进程
php bin/swoft rpc:start

// 守护进程启动,覆盖 .env 守护进程(DAEMONIZE)的配置
php bin/swoft rpc:start -d

// 重启
php bin/swoft rpc:restart

// 重新加载
php bin/swoft rpc:reload

// 关闭服务
php bin/swoft rpc:stop

⁠更新日志

更新日志⁠

⁠开发成员

⁠协议

Swoft的开源协议为Apache-2.0,详情参见LICENSE⁠。

Tag summary

Content type

Image

Digest

Size

160.9 MB

Last updated

over 7 years ago

docker pull swoft/swoft-echo-server