## 路由表達式緩存
It’s possible to enable router cache via`RouteCollector::setCacheFile()`. See examples below:
> 可以通過`RouteCollector::setCacheFile()`來啟用路由器緩存。請參見下面的例子:
~~~php
<?php
use Slim\Factory\AppFactory;
require __DIR__ . '/../vendor/autoload.php';
$app = AppFactory::create();
/**
*要生成路由緩存數據,需要將文件設置為可寫目錄中不存在的文件。
*在第一次運行時生成文件后,只需要文件的讀權限。
*您可能需要在開發環境中生成此文件,并在部署之前將其轉換到您的項目中
*如果您對緩存文件所在的目錄沒有寫權限,那么緩存文件將駐留在部署到的服務器上
* To generate the route cache data, you need to set the file to one that does not exist in a writable directory.
* After the file is generated on first run, only read permissions for the file are required.
*
* You may need to generate this file in a development environment and comitting it to your project before deploying
* if you don't have write permissions for the directory where the cache file resides on the server it is being deployed to
*/
$routeCollector = $app->getRouteCollector();
$routeCollector->setCacheFile('/path/to/cache.file');
~~~
- 開始
- 安裝
- 升級指南
- Web服務器
- 概念
- 生命周期
- PSR 7
- 中間件
- 依賴容器
- 實例 及通知和警告處理
- Request
- 請求方法
- 請求頭信息
- 請求主體
- 上傳的文件
- 請求幫助
- 路由對象
- Response
- 響應狀態
- 響應標頭
- 響應體
- 返回JSON
- 視圖模板
- 路由
- 創建路由
- 路由回調
- 路由策略
- 路線占位符
- 路由名
- 路由組
- 路由中間件
- 路由表達式緩存
- 容器識別解析
- 封裝中間件
- 路由的中間件
- 錯誤處理中間件
- 方法重寫的中間件
- 輸出緩沖中間件
- 內容長度中間件
- 擴展功能
- 以 / 結尾的路由模式
- 獲取當前路由
- 設置CORS
- 使用POST表單上傳文件
- 第三方組件
- slim-session
- auth
- slim-api-skeleton
- dir