OpenWhisk PHP操作将错误显示为输出

时间:2019-01-30 14:22:17

标签: php serverless openwhisk

我正在尝试使用PHP语言创建一个openWhisk PHP操作。 我用以下代码创建了一个 hello.php 文件的PHP文件,

<?php
function main(array $args) : array
{
    $name = $args["name"] ?? "stranger";
    $greeting = "Hello $name!";
    echo $greeting;
    return ["greeting" => $greeting];
}

现在,我尝试通过PHP使用CLI运行命令,

wsk动作创建helloPHP hello.php --kind php:7.3

我已经安装了PHP 7.3并在PHP 7.3中运行以上命令 当我在上面运行命令时,出现如下错误,

error: Unable to create action 'helloPHP': The request content was malformed:
kind 'php:7.3' not in Set(nodejs:10-fat, nodejs:10, nodejs:8, nodejs, blackbox, sequence, nodejs:6) (code FsBP1CzMYjOc7W1HMXBHbK0YabJtCFkN)
Run 'wsk --help' for usage.

1 个答案:

答案 0 :(得分:3)

根据错误消息,您的openwhisk部署中未安装运行时PHP 7.3。您可以编辑运行时清单并重新部署控制器和调用者以添加运行时。这是一个示例运行时清单,它为此版本的运行时https://github.com/apache/incubator-openwhisk/blob/8cd10bb09d64c1bc2638f05d1fb8dadb24b7f36e/ansible/files/runtimes.json#L223-L236添加了PHP类型。

有关清单的更多详细信息。 https://github.com/apache/incubator-openwhisk/blob/master/docs/actions-new.md#the-runtimes-manifest

重新部署整个系统,或者进行更多的外科手术是可行的选择-这取决于您如何管理部署。