lawngnome/phpdbg-fake-request

A CLI script that will fake a HTTP request before delegating control to another PHP script

0.1.2 2016-05-26 17:40 UTC

This package is not auto-updated.

Last update: 2024-11-09 20:39:21 UTC


README

This package provides an executable script that can be used with phpdbg to fake a web request.

Build Status

Installation

composer require lawngnome/phpdbg-fake-request

Usage

To fake a GET request to / with public/index.php as the entry point:

./vendor/bin/fake-request GET / public/index.php

This will launch phpdbg. The script can then be run with phpdbg's run command:

run

Populating $_GET and $_POST

The -g and -p options allow for GET and POST variables to be sent:

./vendor/bin/fake-request GET / public/index.php -g 'page=2'
./vendor/bin/fake-request POST / public/index.php -p 'page=2'

Values do not need to be URL encoded.

Headers

Similarly, the -H option allows for HTTP headers to be sent:

./vendor/bin/fake-request GET / public/index.php -H 'X-Foo: bar'

Cookies

The -c option allows cookies to be sent:

./vendor/bin/fake-request GET / public/index.php -c 'PHPSESSID=foo'

Known issues

Arbitrary POST data is unsupported

It is impossible at present to set the php://input stream up at runtime, so non-form POST data is not supported.

Feedback

Please send issues and pull requests through GitHub.

Acknowledgements

This builds on top of the excellent documentation on the phpdbg site and Symfony's equally excellent console component.

You can also e-mail me at aharvey@php.net, if you feel so inclined.