webman:修改默认页面(v1.5.7)

发布时间 2023-08-19 09:06:25作者: 刘宏缔的架构森林

一,默认页面的内容:

说明:代码位于 app/IndexController.php

参考这个文档:

https://www.workerman.net/doc/webman/route.html

原始代码:显示了README.md这个文件的内容

1
2
3
4
5
6
7
8
9
10
class IndexController
{
    public function index(Request $request)
    {
        static $readme;
        if (!$readme) {
            $readme = file_get_contents(base_path('README.md'));
        }
        return $readme;
    }

二,修改默认页面:

1,修改代码为自定义内容

1
2
3
4
5
6
7
class IndexController
{
    public function index(Request $request)
    {
        $html = "<div style='width:100%;height:100%;font-size: 20px;text-align: center;'>欢迎来到图片管理系统</div>";
        return $html;
    }

2,修改代码后需要执行下面两个命令之一才能使代码生效:

1,restart

liuhongdi@lhdpc:/data/webman/imageadmin$ php start.php restart -d
Workerman[start.php] restart 
Workerman[start.php] is stopping ...
Workerman[start.php] stop success
------------------------------------------- WORKERMAN --------------------------------------------
Workerman version:4.1.13          PHP version:8.1.1           Event-Loop:\Workerman\Events\Select
-------------------------------------------- WORKERS ---------------------------------------------
proto   user            worker          listen                 processes    status           
tcp     liuhongdi       webman          http://0.0.0.0:8787    8             [OK]            
tcp     liuhongdi       monitor         none                   1             [OK]            
--------------------------------------------------------------------------------------------------
Input "php start.php stop" to stop. Start success.

2,reload

liuhongdi@lhdpc:/data/webman/imageadmin$ php start.php reload
Workerman[start.php] reload

3,查看效果:

说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/08/18/webman-xiu-gai-mo-ren-ye-mian-v1-5-7/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com

三,查看webman版本:

liuhongdi@lhdpc:/data/webman/imageadmin$ composer show workerman/webman-framework
name     : workerman/webman-framework
descrip. : High performance HTTP Service Framework.
keywords : High Performance, http service
versions : * v1.5.7
...