-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PHP 7.1 as a kind #2415
Add PHP 7.1 as a kind #2415
Conversation
Without an in depth review: Looks awesomely executed! Thanks for this! |
Travis is reporting Not sure how to fix? |
@akrabat This is an awesome contribution !!! |
@akrabat the problem is nothing to do with ansible/db_local.ini
|
@@ -0,0 +1,470 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it needs to be single /*
to pass the scan
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package actionContainers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add space after the license, just in case
That'll teach me to read the text in bright red/pink! |
cd57afa
to
ecd706a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adjust for dynamic invoker images
ansible/group_vars/all
Outdated
@@ -72,6 +72,11 @@ runtimesManifest: | |||
image: | |||
name: "java8action" | |||
default: true | |||
php: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add deprecated: false
@@ -13,6 +13,7 @@ | |||
- '{{ docker_image_prefix }}/python3action' | |||
- '{{ docker_image_prefix }}/swift3action' | |||
- '{{ docker_image_prefix }}/java8action' | |||
- '{{ docker_image_prefix }}/action-php-v7.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer need it, now the list is not hard coded
@csantanapr Rebased to master & addressed comments. |
@akrabat this is a significant contribution adding a new language support. People can try and maybe comment on this PR with any feedback |
Also I think you need to rebase/merge to upstream/master |
Rebased. |
This is an exciting development. Do you think it could be possible to support dynamic composer dependencies? |
My current view is that you should provide a zip file with your vendor folder in it as it's too slow to fetch dependencies dynamically. This is how it works for NodeJS actions.
Regards,
Rob...
… On 4 Jul 2017, at 11:46, Darren Mothersele ***@***.***> wrote:
This is an exciting development.
Do you think it could be possible to support dynamic composer dependencies?
Perhaps something like http://melody.sensiolabs.org/
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Ping @lornajane for code review & thoughts on list of PHP extensions and Composer modules to include. |
+1 for zip file with vendor folder, if pulling dependencies from composer file is not viable. -1 for including a default set of composer packages. |
Every other OpenWhisk action container ships with some default components - the most obvious ones being easy abilities to invoke other actions. e.g. Swift ships with Kitura-nat, SwiftyJSON and swift-watson-sdk. I think the expectation is that the PHP action should follow suit, so included Guzzle and Uuid. I'm open to arguments on this though. We are completely in agreement that if the user ships their own vendor folder, then it should "win" though :) |
Re: extensions, this set would be good:
Sources: |
The built in packages are convenient - less zip files for the initial ramp up. But it creates a maintenance issue: when do you pick up updates to the packages (minor/patch level only?) and not break existing actions using the "kind". That is: is the kind itself semantically verionsed? @csantanapr, @bjustin-ibm FYI. |
@darrenmothersele Everything on your list except mcrypt is included. I have not included mcrypt it is deprecated in PHP 7.1 as it has been unmaintained since 2007 and abandoned since 2011. It is completely removed from PHP 7.2 and I don't see any point in including it. |
@akrabat cool that sounds good! |
Build the Docker container from php:7.1-alpine and implement the HTTP server using PHP's built in server. Note that when using a zip file, the router requires that the `main` function is stored in `index.php`.
The runner sets the exit code to 1 if it has set the last line of stdout to a string suitable for presentation to the user. Therefore, if the exit code is not one, then display a generic message.
* Add PHP_VERSION for consistency with other kinds. * Add WHISK_INPUT for consistency with Swift kind.
Make it clearer what the router outputs by ensuring all the code that does this at the top. Also, clarify that the body sent back to the client is always JSON and add per-function documentation.
Also remove the duplicated last line if we've sent it to the client.
If there's a runtime error in the action (i.e. not spotted by linter), then looking for the main() function will find it. Render the error to the logs so that the user knows what's happened.
If the PHP vendor file has a vendor directory, then this directory needs to be used rather than the one supplied in the action container. To do this, we require src/vendor/autoload.php which will exist if the zip file contains it. For the cases where zip file does not contain a vendor folder and when running a non-binary code action, we move the container's vendor folder into src/.
Rebased to pick up #2437 |
* Implement PHP 7.1 kind * Add tests for PHP 7.1 action * Add PHP action documentation Build the Docker container from php:7.1-alpine and implement the HTTP server using PHP's built in server. Note that when using a zip file, the router requires that the `main` function is stored in `index.php`. Note about the runner: The runner sets the exit code to 1 if it has set the last line of stdout to a string suitable for presentation to the user. Therefore, if the exit code is not one, then display a generic message. If there's a runtime error in the action (i.e. not spotted by linter), then looking for the main() function will find it. Render the error to the logs so that the user knows what's happened. Note about vendor folder in a PHP zip: If the PHP vendor file has a vendor directory, then this directory needs to be used rather than the one supplied in the action container. To do this, we require src/vendor/autoload.php which will exist if the zip file contains it. For the two cases where (1) zip file does not contain a vendor folder, or (2) when running a non-binary code action, we move the container's vendor folder into src/.
* Implement PHP 7.1 kind * Add tests for PHP 7.1 action * Add PHP action documentation Build the Docker container from php:7.1-alpine and implement the HTTP server using PHP's built in server. Note that when using a zip file, the router requires that the `main` function is stored in `index.php`. Note about the runner: The runner sets the exit code to 1 if it has set the last line of stdout to a string suitable for presentation to the user. Therefore, if the exit code is not one, then display a generic message. If there's a runtime error in the action (i.e. not spotted by linter), then looking for the main() function will find it. Render the error to the logs so that the user knows what's happened. Note about vendor folder in a PHP zip: If the PHP vendor file has a vendor directory, then this directory needs to be used rather than the one supplied in the action container. To do this, we require src/vendor/autoload.php which will exist if the zip file contains it. For the two cases where (1) zip file does not contain a vendor folder, or (2) when running a non-binary code action, we move the container's vendor folder into src/.
* Implement PHP 7.1 kind * Add tests for PHP 7.1 action * Add PHP action documentation Build the Docker container from php:7.1-alpine and implement the HTTP server using PHP's built in server. Note that when using a zip file, the router requires that the `main` function is stored in `index.php`. Note about the runner: The runner sets the exit code to 1 if it has set the last line of stdout to a string suitable for presentation to the user. Therefore, if the exit code is not one, then display a generic message. If there's a runtime error in the action (i.e. not spotted by linter), then looking for the main() function will find it. Render the error to the logs so that the user knows what's happened. Note about vendor folder in a PHP zip: If the PHP vendor file has a vendor directory, then this directory needs to be used rather than the one supplied in the action container. To do this, we require src/vendor/autoload.php which will exist if the zip file contains it. For the two cases where (1) zip file does not contain a vendor folder, or (2) when running a non-binary code action, we move the container's vendor folder into src/.
* Implement PHP 7.1 kind * Add tests for PHP 7.1 action * Add PHP action documentation Build the Docker container from php:7.1-alpine and implement the HTTP server using PHP's built in server. Note that when using a zip file, the router requires that the `main` function is stored in `index.php`. Note about the runner: The runner sets the exit code to 1 if it has set the last line of stdout to a string suitable for presentation to the user. Therefore, if the exit code is not one, then display a generic message. If there's a runtime error in the action (i.e. not spotted by linter), then looking for the main() function will find it. Render the error to the logs so that the user knows what's happened. Note about vendor folder in a PHP zip: If the PHP vendor file has a vendor directory, then this directory needs to be used rather than the one supplied in the action container. To do this, we require src/vendor/autoload.php which will exist if the zip file contains it. For the two cases where (1) zip file does not contain a vendor folder, or (2) when running a non-binary code action, we move the container's vendor folder into src/.
* Implement PHP 7.1 kind * Add tests for PHP 7.1 action * Add PHP action documentation Build the Docker container from php:7.1-alpine and implement the HTTP server using PHP's built in server. Note that when using a zip file, the router requires that the `main` function is stored in `index.php`. Note about the runner: The runner sets the exit code to 1 if it has set the last line of stdout to a string suitable for presentation to the user. Therefore, if the exit code is not one, then display a generic message. If there's a runtime error in the action (i.e. not spotted by linter), then looking for the main() function will find it. Render the error to the logs so that the user knows what's happened. Note about vendor folder in a PHP zip: If the PHP vendor file has a vendor directory, then this directory needs to be used rather than the one supplied in the action container. To do this, we require src/vendor/autoload.php which will exist if the zip file contains it. For the two cases where (1) zip file does not contain a vendor folder, or (2) when running a non-binary code action, we move the container's vendor folder into src/.
* Implement PHP 7.1 kind * Add tests for PHP 7.1 action * Add PHP action documentation Build the Docker container from php:7.1-alpine and implement the HTTP server using PHP's built in server. Note that when using a zip file, the router requires that the `main` function is stored in `index.php`. Note about the runner: The runner sets the exit code to 1 if it has set the last line of stdout to a string suitable for presentation to the user. Therefore, if the exit code is not one, then display a generic message. If there's a runtime error in the action (i.e. not spotted by linter), then looking for the main() function will find it. Render the error to the logs so that the user knows what's happened. Note about vendor folder in a PHP zip: If the PHP vendor file has a vendor directory, then this directory needs to be used rather than the one supplied in the action container. To do this, we require src/vendor/autoload.php which will exist if the zip file contains it. For the two cases where (1) zip file does not contain a vendor folder, or (2) when running a non-binary code action, we move the container's vendor folder into src/.
* Implement PHP 7.1 kind * Add tests for PHP 7.1 action * Add PHP action documentation Build the Docker container from php:7.1-alpine and implement the HTTP server using PHP's built in server. Note that when using a zip file, the router requires that the `main` function is stored in `index.php`. Note about the runner: The runner sets the exit code to 1 if it has set the last line of stdout to a string suitable for presentation to the user. Therefore, if the exit code is not one, then display a generic message. If there's a runtime error in the action (i.e. not spotted by linter), then looking for the main() function will find it. Render the error to the logs so that the user knows what's happened. Note about vendor folder in a PHP zip: If the PHP vendor file has a vendor directory, then this directory needs to be used rather than the one supplied in the action container. To do this, we require src/vendor/autoload.php which will exist if the zip file contains it. For the two cases where (1) zip file does not contain a vendor folder, or (2) when running a non-binary code action, we move the container's vendor folder into src/.
This adds a new
php:7.1
kind to allow PHP actions like this:The PHP runtime is based on the official
php:7.1-alpine
one with the following extensions added:Two Composer packages are also included:
guzzlehttp/guzzle
- A very popular HTTP clientramsey/uuid
- The de facto UUID generatorSuggestions welcome on what should be included in these lists (and of course on the code itself!)
How to test
We need a working local installation. The easiest way to do this is with Vagrant, so that's what this set of steps uses.
Check out the source code
Now change to my branch
Run up the Vagrant box
This takes a while!
I'm not sure what Vagrant is required, but I'm using Vagrant 1.9.1 with VirtualBox 5.1.18. I'm not aware of any other requirements.
You should see output at the end like:
Build the PHP Docker container
This takes a little while while it compiles various PHP bits and bobs.
Testing a PHP action
The vagrant box has a compatible
wsk
in it, so we can use it:If you see:
Then it worked.