1.4升級指南

升級前請做好備份,執行以下命令升級
composer require workerman/webman-framework ^1.4.7 && composer require webman/console ^1.2.12 && php webman install

注意
如果無法升級,很可能是因為使用了composer代理,請使用以下命令 composer config -g --unset repos.packagist 恢復使用composer官方資料源

功能特性及變更

應用插件

1.4版本支援應用插件,更多請參考應用插件

自動路由

1.4版本支援各種複雜的控制器目錄規則,例如

app
app
├── admin
│   └── v1
│       └── v2
│           └── v3
│               └── controller
│                   └── Index.php
└── controller
    ├── v1
    │   └── Index.php
    └── v2
        └── v3
            └── Index.php

也就是說 webman/auto-route 插件不再需要了

控制器重用開關

1.4版本允許關閉控制器重用,在config/app.php中設定'controller_reuse' => false,,這樣每個請求都會重新初始化一個新的控制器,也就是說每個請求都會觸發對應控制器的__construct()構造函數,開發者可以在構造函數中為每個請求執行一些請求處理前的初始化工作。

因為可以關閉控制器重用,所以webman/action-hook 插件不再需要了。

開啟http服務

1.4 版本支援開啟多個端口提供http服務。
參見慢業務處理

視圖檔案配置

後綴只能在view.php 的 options選項中配置。
不再支援的用法

use support\view\Raw;
return [
    'handler' => Raw::class,
    'view_suffix' => '.php'
];

正確的用法

use support\view\Raw;
return [
    'handler' => Raw::class,
    'options' => [
        'view_suffix' => '.php'
    ]
];

session驅動命名空間變動

webman從1.4.0起更改了SessionHandler類的命名空間,由原來的

use Webman\FileSessionHandler;  
use Webman\RedisSessionHandler;  
use Webman\RedisClusterSessionHandler;  

改為

use Webman\Session\FileSessionHandler;  
use Webman\Session\RedisSessionHandler;  
use Webman\Session\RedisClusterSessionHandler;

為了避免升級後程式直接報錯,Webman\FileSessionHandler類仍然被保留一段時間,在未來版本中會被徹底移除。

此變更影響config/session.php'handler'配置。