Skip to content

Repository files navigation

swoft

Latest VersionBuild StatusPhp VersionSwoole VersionHiredis VersionSwoft DocSwoft License

简介

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

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

文档

中文文档

QQ交流群:548173319

环境要求

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

安装

  • composer require swoft/framework dev-master

配置

复制项目根目录的 .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@swoftbin]# php swoft -h______ _
/___|______/_||_
\___ \ \ /\ //_ \||_|__|___) \ VV/ (_) |_||_|____/ \_/\_/ \___/|_| \__|Usage:
phpswoft-hCommands:
entitythegroupcommandlistofdatabaseentityrpcthegroupcommandlistofrpcserverserverthegroupcommandlistofhttp-serverOptions:
-v,--versionshowversion-h,--helpshowhelp

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

About

php high performance coroutine framework base on swoole

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages