> ## Documentation Index
> Fetch the complete documentation index at: https://docs.valyent.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP

> Learn how to deploy a simple PHP application to Valyent

## Introduction

PHP is a popular server-side scripting language that makes it easy to create dynamic web pages. This guide will help you deploy a simple PHP application.

## Prerequisites

* a UNIX-like system (see [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) if you are using Windows), in order to use the [Valyent CLI](https://docs.valyent.cloud/cli)
* a Valyent account, with a registered payment method (you can sign up [here](https://console.valyent.cloud/auth/sign-up))
* [PHP](https://www.php.net/downloads.php) installed on your machine

## Installing the CLI

```bash theme={"system"}
curl -L https://cli.valyent.cloud | sh
```

You can inspect the installation script [here](https://cli.valyent.cloud) and the [GitHub repository](https://github.com/valyentdev/cli).

## Authenticating

```bash theme={"system"}
valyent auth login
```

## Initializing the project

First, let's create a new directory and add our PHP file:

```bash theme={"system"}
mkdir php-app && cd php-app
touch index.php
```

In the `index.php` file, add this simple code:

```php theme={"system"}
<?php
echo "Hello, World!";
```

Now, initialize the `valyent.toml` configuration file:

```bash theme={"system"}
valyent init
```

This command will ask you to select/create a project and an associated application.

## Adding the Dockerfile

Create a Dockerfile for the application:

```bash theme={"system"}
touch Dockerfile
```

Add the following content:

```dockerfile theme={"system"}
# Use the official PHP Apache image
FROM php:8.2-apache

# Copy the application files to the web server's document root
COPY . /var/www/html/

# Set appropriate permissions for the document root
RUN chown -R www-data:www-data /var/www/html

# Expose port 80
EXPOSE 80
```

## Deploy the project

To expose the application’s port, we need to set up a gateway (in this case, the port 80):

```bash theme={"system"}
valyent gateways create
```

Deploy your application to Valyent:

```bash theme={"system"}
valyent deploy
```

Once the deployment is finished, open your application:

```bash theme={"system"}
valyent open
```

Your simple PHP application should now display "Hello, World!" in the browser.
