关于php:JKDYAF-V200-基于-YAF-SWOOLE-APi框架

2次阅读

共计 2226 个字符,预计需要花费 6 分钟才能阅读完成。

JKDYAF – V2.0.0

基于 YAF + SWOOLE APi 框架

       ____ __ ______  _____    ______
      / / //_// __ \ \/ /   |  / ____/
 __  / / ,<  / / / /\  / /| | / /_
/ /_/ / /| |/ /_/ / / / ___ |/ __/
\____/_/ |_/_____/ /_/_/  |_/_/

介绍

简略、间接、非传统

JkdYaf 一个简略、高性能常驻内存的 PHP 框架。

基于 Yaf 与 Swoole 开发,性能较传统基于 PHP-FPM 的框架有质的晋升。

一款专为 Api 开发的轻量级框架。一款面向中小型企业级我的项目的高可用、低门槛 PHP 开源框架。

具体文档

个性

  • HTTP 服务
  • Redis 连接池
  • Jwt 认证
  • 协程化
  • 定时工作
  • 日志治理
  • 路由治理
  • Yac 无锁共享内存

服务器要求

  • php 7.x 或更高版本
  • yaf 3.3.x 或更高版本
  • swoole 5.4.x 或更高版本
  • mysql
  • redis
  • yac

装置 JkdYaf

git clone https://github.com/crytjy/JkdYaf.git

php.ini 配置

extension=yaf.so
[yaf]   
yaf.environ=product
yaf.cache_config=1
yaf.use_namespace=1
yaf.library="/path/JkdYafLibrary/"  // 全局类库的目录门路
    
extension=yac.so
[yac]
; 是否开启 yac,1 示意开启,0 示意敞开
yac.enable=1 
;4M 能够失去 32768 个 key,32M 能够失去 262144 个 key
yac.keys_memory_size=4M
; 申请的最大 value 内存
yac.values_memory_size = 64M 
; 是否压缩数据 ss
yac.compress_threshold = '-1' 
; 敞开在 cli 下应用 yac
yac.enable_cli = 1

批改后须要重启 php service php-fpm restart

app.ini 配置

我的项目 conf/app.ini

[common]
application.directory = APP_PATH "/app"
application.dispatcher.catchException = TRUE
application.dispatcher.throwException = TRUE
; 本地类库
application.library = APP_PATH "/library"
application.library.namespace = "Com"
; 多模块(多个模块)application.modules = "Api"
; 域名
siteUrl = "http://localhost/"
; 公共类库门路(该门路必须和 php.ini 配置里填写的统一)comLibsPath = "/www/wwwroot/yaf/yafLibrary/"

#数据库配置
[db]
db.host = "localhost"
db.port = 3306
db.dbname = "dbname"
db.username = "username"
db.password = "password~"
db.charset = "utf8mb4"

#日志配置
[log]
; 日志保留天数
log.day = 7
; 日志门路
log.path = APP_PATH "/runtime/log/"

[product : common : db : log]

jkdYaf.ini 配置

我的项目 conf/jkdYaf.ini

; JKDYAF 配置
[common]
ip = "0.0.0.0"
port = 12222    // 监听端口,随便改
app_name = JkdYaf   // 项目名称(英文),多个我的项目时辨别
master_process_name = JkdYaf-Master
manager_process_name = JkdYaf-Manager
event_worker_process_name = JkdYaf-Worker-%s
event_tasker_process_name = JkdYaf-Tasker-%s

; 记录 master 和 manager 的过程 id
pid_file = APP_PATH "/runtime/master.pid"
; 记录 worker 的过程 id
worker_pid_file = APP_PATH "/runtime/worker.pid"
; 记录 tasker 的过程 id
tasker_pid_file = APP_PATH "/runtime/tasker.pid"
; 记录 timer 的过程 id
timer_pid_file = APP_PATH "/runtime/timer.pid"

; 以下参数依据服务器配置相应改变
[server]
process_num = 1
worker_num = 4
max_request = 30000
dispatch_mode = 3
log_file = APP_PATH "/runtime/swoole.log"
log_rotation = SWOOLE_LOG_ROTATION_DAILY

[product : common : server]

启动

配置好后,进入我的项目根目录,启动我的项目

cd /yaf/
php bin/JkdYaf.php start 
php bin/JkdYaf.php start -d  // 守护过程 

浏览器拜访 http://localhost:12222/api/index

{“code”:1,”message”:”success”,”data”:”Hello JkdYaf !”}

正文完
 0