mezon/request
Composer 安装命令:
composer require mezon/request
包简介
Small script for parameters fetcher
README 文档
README
Intro
This class will help you to fetch data from $_POST and $_GET arrays.
Installation
Just print in console
composer require mezon/request
And that's all )
Learn more
More information can be found here:
How to start
The firs steps are quite simple
var_dump(Request::getParam('some-param', 'default'));// will be outputted 'default' $_GET['some-param'] = 'some-value'; var_dump(Request::getParam('some-param'));// will be outputted 'some-value'
Fields priorities
In case you have the same parameters in $_GET, $_POST and other global arrays, then they will be prioritized in this way:
- security tokens in HTTP headers
- Router parameters
- HTTP request headers
- $_POST
- $_GET
For example:
$_GET['some-param'] = 'get-value'; $_POST['some-param'] = 'post-value'; var_dump(Request::getParam('some-param'));// will be outputted 'post value'
Router parameters
You can pass your Router object to this class and fetch parameters for non-static routes:
Request::registerRouter(<your Mezon\Router object>);
Security tokens in HTTP headers
There are a way to fetch security token from headers:
- Authentication
- Authorization
- Cgi-Authorization
For example if you will pass in headers something like that:
Authorization: Basic <some token>
And then call:
Request::getParam('session_id')
Then this call will return <some token>.
Wrappers
There are some convenient wrappers were implemented:
// will return true if the parameter exists // will return false otherwise Request::wasSubmitted('param-name')
Or wrapper for check-boxes:
Request::getChecked('param-name', ['switched on', 'switched off']) Request::getChecked('param-name', [1, 0]) Request::getChecked('param-name', [true, false])
In this call the method getChecked will return the first element of the array which is passed as the second parameter. And the second element otherwise.
mezon/request 适用场景与选型建议
mezon/request 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.22k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 12 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mezon/request 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mezon/request 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 5
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-22