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' 配置。