Home > Backend Development > PHP Tutorial > PHP coroutine framework Hyperf log viewing component

PHP coroutine framework Hyperf log viewing component

藏色散人
Release: 2023-04-09 15:26:02
forward
5112 people have browsed it

Recently, I need to use the function of using routing to view PHP coroutine framework Hyperf log viewing component logs online in Hyperf. I haven’t found one that’s easy to use, so I simply wrote one myself, which supports viewing and simple content search.

1. Interface

First, the rendering:

PHP coroutine framework Hyperf log viewing component

2. Use

  • 1. Install components

composer require sett/hyperf-log-viewer

  • 2 .Publish configuration PHP coroutine framework Hyperf log viewing component

php bin/hyperf.php vendor:publish sett/hyperf-log-viewer

  • 3.Register route

Router::get('/logs', 'Sett\LogViewer\Controller\LogViewController@index');

  • 4. Install the view component

composer require hyperf/view

  • 5. Install the template engine

composer require sy- records/think-template

  • 6. Configuration view

In the config\autoload\viewe.php PHP coroutine framework Hyperf log viewing component (if it does not exist, create it yourself ), add the following view configuration

return [
        'engine' => ThinkEngine::class,
        'mode'   => Mode::TASK,
        'config' => [
            // 若下列文件夹不存在请自行创建
            'view_path'  => BASE_PATH . '/storage/view/',
            'cache_path' => BASE_PATH . '/runtime/view/',
        ],];
Copy after login
  • 7. Configure component parameters

In the config\autoload\logViewer.php PHP coroutine framework Hyperf log viewing component, add your own Log PHP coroutine framework Hyperf log viewing component directory

return [ 
   "path" => BASE_PATH . "/runtime/logs/", 
   "pattern" => "*.log", 
   "size" => 10 
   ];
Copy after login

3. Description

  • The log time format only supports the year, month, day, hour, minute and second format, otherwise you may not be able to see the record

The above is the detailed content of PHP coroutine framework Hyperf log viewing component. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template