一,官方文档地址:
https://www.workerman.net/doc/webman/config.html
二,代码:
1, .env:
GOODS_IMAGE_DIR=/var/www/html/goodsImage
GOODS_IMAGE_HOST=http://192.168.219.6
2,config/images.php
1
2
3
4
5
|
<?php return [ "goodsImageDir" => getenv ( 'GOODS_IMAGE_DIR' ), "goodsImageHost" => getenv ( 'GOODS_IMAGE_HOST' ), ]; |
3,controller/ImageController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<?php namespace app\controller; use support\Request; use app\result\Result; use support\Log; use think\facade\Db; use think\facade\Cache; use app\model\Comment as CommentModel; class ImageController { //图片的详情 public function detail(Request $request ) { //用config函数获取变量值 $dir = config( 'images.goodsImageDir' ); $host = config( 'images.goodsImageHost' ); //返回数据 $data = [ "dir" => $dir , "host" => $host , ]; return Result::Success( $data ); } |
说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/08/23/webman-zi-ding-yi-pei-zhi-wen-jian-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
...