webman:请求参数(v1.5.7)
一,官方文档:
https://www.workerman.net/doc/webman/request.html
二,示例代码:
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
27
28
29
30
31
32
|
<?php namespace app\controller; use support\Request; use app\result\Result; class ImageController { //图片的列表 public function list(Request $request ) { //$request包含了请求的参数 $page = $request ->get( 'page' ); //request()也返回请求对象 $size = request()->get( 'size' ); //指定默认值 $type = $request ->get( 'type' , 'mobile' ); //不指定默认值 $order = $request ->get( 'order' ); //all()包含post get 的集合 $all = $request ->all(); //返回 $res = [ 'page' => $page , 'size' => $size , 'type' => $type , 'order' => $order , 'all' => $all , ]; return Result::Success( $res ); } } |
说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/08/18/webman-qing-qiu-can-shu/
代码: 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
...