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