How do I emulate a typical request #66
-
Using Codeigniter 4. Attempting to hit a controller router but $_REQUEST in the script is blank? $_SERVER has REQUEST_URI Example below:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi John, thanks for your request! In the code above you did not add any content that would fill the In order to do so you'd need to pass data to the second parameter for the For example, if you want to have "Hello world" as the value of the key "test" in your $client = new Client();
$connection = new NetworkSocket('localhost', 9000);
$data = [
'test' => 'Hello world',
];
$content = http_build_query($data);
$request = new GetRequest('/var/ci4/public/index.php', $content);
$request->setRequestUri('/home/testagain');
$response = $client->sendRequest($connection, $request);
echo $response->getBody(); This is also noted in the docs: https://github.com/hollodotme/fast-cgi-client#send-request-synchronously By default the content type of the request content is Hope this helps. |
Beta Was this translation helpful? Give feedback.
Hi John, thanks for your request!
In the code above you did not add any content that would fill the
$_REQUEST
array as far as I can see.In order to do so you'd need to pass data to the second parameter for the
GetRequest
instance.For example, if you want to have "Hello world" as the value of the key "test" in your
$_REQUEST
array, the code would look like this: