lawngnome / phpdbg-fake-request
一个命令行脚本,在委托控制到另一个PHP脚本之前,将模拟HTTP请求
0.1.2
2016-05-26 17:40 UTC
Requires
- php: >=7
- symfony/console: ^3
Requires (Dev)
- phpunit/phpunit: ^5.3
This package is not auto-updated.
Last update: 2024-09-14 19:36:41 UTC
README
此包提供了一个可执行脚本,可用于与 phpdbg 一起模拟网络请求。
安装
composer require lawngnome/phpdbg-fake-request
用法
使用 public/index.php 作为入口点模拟对 / 的 GET 请求
./vendor/bin/fake-request GET / public/index.php
这将启动 phpdbg。然后可以使用 phpdbg 的 run 命令运行脚本
run
填充 $_GET 和 $_POST
使用 -g 和 -p 选项可以发送GET和POST变量
./vendor/bin/fake-request GET / public/index.php -g 'page=2' ./vendor/bin/fake-request POST / public/index.php -p 'page=2'
值无需URL编码。
头部信息
类似地,使用 -H 选项可以发送HTTP头部信息
./vendor/bin/fake-request GET / public/index.php -H 'X-Foo: bar'
Cookie
使用 -c 选项可以发送Cookie
./vendor/bin/fake-request GET / public/index.php -c 'PHPSESSID=foo'
已知问题
不支持任意POST数据
目前无法在运行时设置 php://input 流,因此不支持非表单POST数据。
反馈
请通过 GitHub 发送问题和拉取请求。
致谢
这基于 phpdbg 网站上优秀的 文档 和 Symfony 同样优秀的 控制台组件。
如果您愿意,也可以通过 aharvey@php.net 发送电子邮件给我。