PHP code example of jakubboucek / openwhisk-runtime
1. Go to this page and download the library: Download jakubboucek/openwhisk-runtime library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use JakubBoucek\OpenWhisk\Runtime\Response;
function main(array $args) : array
{
$name = $args['name'] ?? 'stranger';
$greeting = "Hello $name!";
return new Response\RawResponse(['body' => $greeting, 'headers' => ['Content-Type' => 'text/html; charset=utf-8']]);
}
use JakubBoucek\OpenWhisk\Runtime\Response;
function main(array $args) : array
{
$name = $args['name'] ?? 'stranger';
$greeting = "Hello $name!";
return new Response\RawJsonResponse(['message' => $greeting]);
}
use JakubBoucek\OpenWhisk\Runtime\Response;
function main(array $args) : array
{
if (!isset($args['name'])) {
return (new Response\HttpResponse("Error: Missing ttpResponse($greeting))
->setContentType(Response\HttpHeader::PlainContentType);
}
use JakubBoucek\OpenWhisk\Runtime\Response;
function main(array $args) : array
{
$name = $args['name'] ?? 'stranger';
$greeting = sprintf('Hello <strong>%s</strong>!', htmlspecialchars($name));
return new Response\HtmlResponse($greeting);
}
use JakubBoucek\OpenWhisk\Runtime\Response;
function main(array $args) : array
{
if (!isset($args['name'])) {
return (new Response\JsonResponse(['error' =>"Error: Missing
use JakubBoucek\OpenWhisk\Runtime\Response;
use JakubBoucek\OpenWhisk\Runtime\Source;
function main(array $args) : array
{
$response = new Response\DynamicResponse(new Source\OutputBuffer());
echo 'Dumping $args variable:' . "\n";
var_dump($args);
return $response;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.