【相關(guān)學(xué)習(xí)推薦:php圖文教程】
最近在Hyperf中需要用到使用路由在線查看文件日志的功能,沒有發(fā)現(xiàn)比較好用的,自己簡單寫了一個(gè),支持查看和簡單的內(nèi)容搜索。
一、界面
先上效果圖:
二、使用
- 1.安裝組件
composer require sett/hyperf-log-viewer
- 2.發(fā)布配置文件
php bin/hyperf.php vendor:publish sett/hyperf-log-viewer
- 3.注冊(cè)路由
Router::get('/logs', 'SettLogViewerControllerLogViewController@index');
- 4.安裝view組件
composer require hyperf/view
- 5.安裝模板引擎
composer require sy-records/think-template
- 6.配置視圖
return [ 'engine' => ThinkEngine::class, 'mode' => Mode::TASK, 'config' => [ // 若下列文件夾不存在請(qǐng)自行創(chuàng)建 'view_path' => BASE_PATH . '/storage/view/', 'cache_path' => BASE_PATH . '/runtime/view/', ],];
- 7.配置組件參數(shù)
在configautoloadlogViewer.php文件中,添加自己的日志文件目錄
return [ "path" => BASE_PATH . "/runtime/logs/", "pattern" => "*.log", "size" => 10 ];
三、說明
- 日志時(shí)間格式只支持年月日時(shí)分秒格式,否則可能看不到記錄
相關(guān)學(xué)習(xí)推薦:php編程(視頻)