Skip to content
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
6 changes: 4 additions & 2 deletions serving/samples/helloworld-php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ FROM php:7.2.6-apache

COPY index.php /var/www/html/

# Run on port 8080 rather than 80
RUN sed -i 's/80/8080/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
ENV PORT 8080

# Use the PORT environment variable in Apache configuration files.
RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
15 changes: 8 additions & 7 deletions serving/samples/helloworld-php/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Hello World - PHP sample

A simple web app written in PHP that you can use for testing.
It reads in an env variable `TARGET` and prints "Hello World: ${TARGET}". If
TARGET is not specified, it will use "NOT SPECIFIED" as the TARGET.
It reads in an env variable `TARGET` and prints "Hello ${TARGET}!". If
TARGET is not specified, it will use "World" as the TARGET.

## Prerequisites

Expand All @@ -29,9 +29,8 @@ following instructions recreate the source files from this folder.

```php
<?php
$target = getenv('TARGET', true) ?: "World";
echo sprintf("Hello %s!\n", $target);
?>
$target = getenv('TARGET', true) ?: "World";
echo sprintf("Hello %s!\n", $target);
```

1. Create a file named `Dockerfile` and copy the code block below into it.
Expand All @@ -42,8 +41,10 @@ following instructions recreate the source files from this folder.

COPY index.php /var/www/html/

# Run on port 8080 rather than 80
RUN sed -i 's/80/8080/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
ENV PORT 8080

RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf

```

1. Create a new file, `service.yaml` and copy the following service definition
Expand Down
5 changes: 2 additions & 3 deletions serving/samples/helloworld-php/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?php
$target = getenv('TARGET', true) ?: "World";
echo sprintf("Hello %s!\n", $target);
?>
$target = getenv('TARGET', true) ?: 'World';
echo sprintf('Hello %s!\n', $target);