Pragmatism in the real world

Notes for working on the OpenWhisk PHP Runtime

These are some notes for working on the OpenWhisk PHP Runtime, but are probably applicable to the other runtimes too.

Setting up

I have a clone of the runtimes I’m interested in and core side-by-side in a directory.

You then need various tools for development, which are documented here for macOS & Ubuntu in the Prerequites section.

Build the container

The PHP runtime creates two containers, one for PHP 7.1 and one for PHP 7.2. To build them we use Gradle:

$ ./gradlew :core:php7.2Action:distDocker
$ ./gradlew :core:php7.1Action:distDocker

This will create the images action-php-v7.1 and action-php-v7.2 with aliases whisk/action-php-v7.1 & whisk/action-php-v7.2 respectively.


Run the tests using:

$ ./gradlew :tests:test

This will run all the tests for both containers. If you need to run just one container’s test, then use the --tests filter:

$ ./gradlew tests:test --tests actionContainers.Php72ActionContainerTests

The tests use the BasicActionRunnerTests from core. If you have modified those, then you need to import them into your local Maven repo using:

$ cd path/to/incubator-openwhisk
$ ./gradlew :tests:install

You can then go back to the runtime directory and run the tests and they will pick up your local changes from core.

Interactive testing of a container

You can test the container using your local install of OpenWhisk.

Alternatively you can test directly against the container using the handy script that lives in core’s tools/actionProxy directory:

Firstly run action container:

$ docker run -i -t -p 8080:8080 action-php-v7.2

Then, in a different terminal:

$ cd path/to/test/actions
$ /path/to/incubator-openwhisk/tools/actionProxy/ init hello.php
$ /path/to/incubator-openwhisk/tools/actionProxy/ run '{"name": "Rob"}'

Note that you don’t pass the action name to `` because we’re working at the container level and there can be only one action for each container instance. This means that you need to stop the container and restart it to init a new action.

You can test zip files too by passing your zip file to ` init`:

$ cp hello.php index.php 
$ zip index.php
$ /path/to/incubator-openwhisk/tools/actionProxy/ init
$ /path/to/incubator-openwhisk/tools/actionProxy/ run '{"name": "Rob"}'

Note that as the zip file must have a file called index.php in it, so we copy hello.php to index.php first.

Checking the formatting of Scala files

Travis runs on each PR raised. One thing it will do is check the formatting of the Scala. Check locally using:

$ ./gradlew :tests:checkTestScalafmt


The tooling available for working on a single action runtime makes it reasonably easy to concentrate on the job in hand and you don’t need to worry about building the rest of OpenWhisk at the same time.

One thought on “Notes for working on the OpenWhisk PHP Runtime

  1. You could use redo (aka wskdev)

    > pwd
    > redo runtime:php7.1Action --dir . -n
    build a php7.1Action runtime action container
    ./gradlew core:php7.1Action:distDocker  --parallel 

Comments are closed.