Workerman\Events\Revolt
改名為Workerman\Events\Fiber
,并且不會自動開啟,需要手動開啟 ($worker->eventLoop = Fiber::class
)PHP>=8.0
更多參考 升級到1.6
支持自定義應用插件 public 目錄
優(yōu)化Model DIE智能提示
增加超全局中間件
支持跨應用設置中間件
增加助手函數(shù)input()
支持 mongodb/laravel-mongodb
路由分組支持在任意位置設置中間件
$request->getRealIp() 增加合法性檢查
view(string $template, array $vars = [], string $app = null, string $plugin = null)
支持plugin參數(shù)
windows下使用PHP_BINARY常量對應的php啟動
支持workerman v5協(xié)程版本
增加support\Context類用于記錄協(xié)程上下文
更多參考 https://github.com/walkor/webman-framework/releases
利用命令composer create-project workerman/webman
新建的webman項目 app.controller_reuse
配置將默認為
false
,開發(fā)者仍然可以手動將其設置為true
開啟控制器復用。
此變動不影響老項目。
提示
很多開發(fā)者習慣了傳統(tǒng)框架每個請求都重新初始化一個控制器的模式,所以官方默認將控制器復用關閉。
關閉控制器復用后helloworld
壓測性能損失約10%左右,但真實業(yè)務下性能損失可以忽略不計。
例子
<?php
namespace app\controller;
use app\model\User;
use support\Request;
class User
{
public function find(Request $request, User $user)
{
return $user->find(1);
}
}
感謝 377960738 的貢獻
例如
public_path('css/main.css');
//相當于
public_path() . '/css/main.css';
感謝 377960738 的貢獻
參見 https://github.com/walkor/webman-framework/pull/69
感謝 krissss 的貢獻
-
)格式例如 /user/login-check
等同于 /user/loginCheck
等同于 /user/logincheck
其它更多變更請參考 github
__construct()
方法,無需再安裝action-hook插件$request->plugin
屬性,用于標記當前請求屬于哪個插件更多參考 webman1.4升級指南
$response->exception();
獲取業(yè)務異常$request->route->param();
獲取路由參數(shù)support/helpers.php
$request->getRealIp()
方法server.stop_timeout
配置,用于控制停止webman的超時時間(需要workerman>=4.0.34),默認2秒。Workerman\Protocols\Http\Request::sessionId($sid)
支持sid函數(shù)RedisClusterSessionHandler
RedisSessionHandler
支持 心跳和重連Workerman\Worker::$stopTimeout
參數(shù),用于控制停止workerman的超時時間webman/support
目錄中大部分文件移動至 webman-framework/src/support
方便升級注意
升級前先做好備份
最近阿里云composer鏡像停止了更新,所以使用阿里云鏡像無法更新最新版本webman。
請執(zhí)行命令composer config -g --unset repos.packagist
暫時關閉阿里云代理,再升級webman
webman 1.2.x 升級方式
composer require workerman/webman-framework ^1.3.0 && composer require webman/console ^1.0.16 && ./webman install
webman 1.x 升級方式
重新創(chuàng)建項目 composer create-project workerman/webman
,然后將原來項目中app目錄、config目錄覆蓋到新項目。
event-loop
設置event_loop
默認為空,系統(tǒng)會自動選擇最優(yōu)的事件循環(huán)庫。'event_loop' => Workerman\Events\Swoole::class,
request_class
設置request_class
默認使用 support\Request::class
public_path
runtime_path
目錄設置,用于設置靜態(tài)文件目錄和rutime目錄需要webman>=1.2.2 webman-framework>=1.2.1
增加phar打包功能,可將webman項目打包成一個phar文件,方便部署。
參見 phar打包
增強windows支持,支持自定義進程和文件更新檢測重啟
windows啟動方式,雙擊windows.bat,或者運行 php windows.php start
升級方式
一個超級好用的推送組件,強烈推薦。
參考 http://wtbis.cn/doc/webman/plugin/push.html
需要webman>=1.2.2 webman-framework>=1.2.1
需要webman>=1.2.2 webman-framework>=1.2.1
增加以下命令
version
打印webman版本號route:list
打印當前路由配置make:controller
創(chuàng)建一個控制器文件make:model
創(chuàng)建一個model文件make:middleware
創(chuàng)建一個中間件文件make:command
創(chuàng)建自定義命令文件plugin:create
創(chuàng)建一個插件項目plugin:export
導出插件項目Route::getRoutes();
方法用于獲取全部路由config()
獲取其它配置文件內(nèi)容