district5/php-postman-detect
最新稳定版本:0.0.1
Composer 安装命令:
composer require district5/php-postman-detect
包简介
Postman detector is a PHP library that detects if a request has been made by Postman.
README 文档
README
Prevent or restrict access to certain API endpoints when using Postman for mock requests.
Usage...
"repositories":[
{
"type": "vcs",
"url": "git@github.com:district-5/php-postman-detect.git"
}
],
"require": {
"district5/php-postman-detect": ">=0.0.1"
}
Code usage...
<?php $_SERVER['HTTP_USER_AGENT'] = 'PostmanRuntime/7.26.8'; \District5\PostmanDetect\PostmanDetector::isPostman(); // true $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko)'; \District5\PostmanDetect\PostmanDetector::isPostman(); // false $_SERVER['HTTP_USER_AGENT'] = 'PostmanRuntime/7.26.8'; // Disallow this endpoint with Postman always \District5\PostmanDetect\PostmanDetector::disallowAlways(); // throws exception // Current environment is 'local' // disallow on production \District5\PostmanDetect\PostmanDetector::disallowOnEnvs('local', ['prod']); // no exception // disallow on production and staging \District5\PostmanDetect\PostmanDetector::disallowOnEnvs('local', ['prod', 'staging']); // no exception // Current environment is 'prod' // disallow on production \District5\PostmanDetect\PostmanDetector::disallowOnEnvs('prod', ['prod']); // throws exception // disallow on production and staging \District5\PostmanDetect\PostmanDetector::disallowOnEnvs('prod', ['prod', 'staging']); // throws exception
Testing...
composer install
./vendor/bin/phpunit
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: mit
- 更新时间: 2023-07-06