# 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 \${TARGET}!". If TARGET is not specified, it will use "World" as the TARGET. ## Prerequisites - A Kubernetes cluster with Knative installed. Follow the [installation instructions](https://github.com/knative/docs/blob/master/install/README.md) if you need to create one. - [Docker](https://www.docker.com) installed and running on your local machine, and a Docker Hub account configured (we'll use it for a container registry). ## Recreating the sample code While you can clone all of the code from this directory, hello world apps are generally more useful if you build them step-by-step. The following instructions recreate the source files from this folder. 1. Create a new directory and cd into it: ```shell mkdir app cd app ``` 1. Create a file named `index.php` and copy the code block below into it: ```php /dev/null; then INGRESSGATEWAY=istio-ingressgateway fi kubectl get svc $INGRESSGATEWAY --namespace istio-system NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE xxxxxxx-ingressgateway LoadBalancer 10.23.247.74 35.203.155.229 80:32380/TCP,443:32390/TCP,32400:32400/TCP 2d ``` 1. To find the URL for your service, use ``` kubectl get ksvc helloworld-php --output=custom-columns=NAME:.metadata.name,DOMAIN:.status.domain NAME DOMAIN helloworld-php helloworld-php.default.example.com ``` 1. Now you can make a request to your app to see the result. Replace `{IP_ADDRESS}` with the address you see returned in the previous step. ```shell curl -H "Host: helloworld-php.default.example.com" http://{IP_ADDRESS} Hello World: PHP Sample v1! ``` ## Removing the sample app deployment To remove the sample app from your cluster, delete the service record: ```shell kubectl delete --filename service.yaml ```