Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit b91dc3e

Browse files
matthewpoerclareliguori
authored andcommitted
Update Guzzle call in PHP runtime (#20)
* Update example PHP runtime with changes requested by guzzle tool, which as of v6 deprecates use of POST'ing body in this way * Replaced by simply `json_encode()`ing the response payload and updating the hello/goodbye example functions to provide array output
1 parent 098d127 commit b91dc3e

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

example/function/src/goodbye.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
function goodbye($data)
77
{
8-
return "Goodbye, {$data['name']}!";
8+
$response = [
9+
'msg' => "Goodbye, {$data['name']}!",
10+
'data' => $data
11+
];
12+
return $response;
913
}
10-
11-
?>

example/function/src/hello.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
function hello($data)
77
{
8-
return "Hello, {$data['name']}!";
8+
$response = [
9+
'msg' => "Hello, {$data['name']}!",
10+
'data' => $data
11+
];
12+
return $response;
913
}
10-
11-
?>

example/runtime/bootstrap

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ function sendResponse($invocationId, $response)
2222
{
2323
$client = new \GuzzleHttp\Client();
2424
$client->post(
25-
'http://' . $_ENV['AWS_LAMBDA_RUNTIME_API'] . '/2018-06-01/runtime/invocation/' . $invocationId . '/response',
26-
['body' => $response]
25+
'http://' . $_ENV['AWS_LAMBDA_RUNTIME_API'] . '/2018-06-01/runtime/invocation/' . $invocationId . '/response',
26+
['body' => json_encode($response)]
2727
);
2828
}
2929

@@ -42,5 +42,3 @@ do {
4242
// Submit the response back to the runtime API.
4343
sendResponse($request['invocationId'], $response);
4444
} while (true);
45-
46-
?>

0 commit comments

Comments
 (0)