Skip to content
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

PHP version update #266

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This repository contains the Classic OpenFaaS templates, but many more are avail
| java11-vert-x | Java and [Vert.x](https://vertx.io/) | 11 | Debian GNU/Linux | of-watchdog | [Java LTS template](https://github.com/openfaas/templates/tree/master/template/java11-vert-x)
| java11 | Java | 11 | Debian GNU/Linux | of-watchdog | [Java LTS template](https://github.com/openfaas/templates/tree/master/template/java11)
| ruby | Ruby | 2.7 | Alpine Linux 3.11 | classic| [Ruby template](https://github.com/openfaas/templates/tree/master/template/ruby)
| php7 | PHP | 7.2 | Alpine Linux | classic | [PHP 7 template](https://github.com/openfaas/templates/tree/master/template/php7)
| php7 | PHP | 7.4 | Alpine Linux | classic | [PHP 7 template](https://github.com/openfaas/templates/tree/master/template/php7)
| csharp | C# | N/A | Debian GNU/Linux 9 | classic | [C# template](https://github.com/openfaas/templates/tree/master/template/csharp)

For more information on the templates check out the [docs](https://docs.openfaas.com/cli/templates/).
Expand Down
4 changes: 2 additions & 2 deletions template/php7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ ARG BUILDPLATFORM
FROM --platform=${TARGETPLATFORM:-linux/amd64} ghcr.io/openfaas/classic-watchdog:0.1.5 as watchdog

# start with the official Composer image and name it
FROM --platform=${TARGETPLATFORM:-linux/amd64} composer:1.7 AS composer
FROM --platform=${TARGETPLATFORM:-linux/amd64} composer:1 AS composer

# continue with the official PHP image
FROM --platform=${TARGETPLATFORM:-linux/amd64} php:7.2-alpine
FROM --platform=${TARGETPLATFORM:-linux/amd64} php:7.4-alpine

# copy the Composer PHAR from the Composer image into the PHP image
COPY --from=composer /usr/bin/composer /usr/bin/composer
Expand Down
6 changes: 3 additions & 3 deletions template/php7/function/src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
class Handler
{
/**
* @param $data
* @return
* @param string $data
* @return string
*/
public function handle($data)
public function handle(string $data): string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before you made this explicitly into a string, what kind of data was being passed in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was/is string, it gets data directly from file_get_contents("php://stdin"), which is read the entire stdin into a string or return false on failure (in case of an explicit php://stdin should never happen).
https://www.php.net/manual/en/function.file-get-contents

The explicit string type is only there to aid the developer, nothing fancy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying.

{
return $data;
}
Expand Down
2 changes: 1 addition & 1 deletion template/php7/template.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: php7
fprocess: php index.php
welcome_message: |
You have created a new function which uses PHP 7.2.
You have created a new function which uses PHP 7.4.
Dependencies and extensions can be added using the composer.json
and php-extension.sh files.
See https://github.com/openfaas/templates/blob/master/template/php7.