> For the complete documentation index, see [llms.txt](https://docs.discloud.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.discloud.com/en/development-environment/supported-languages/php.md).

# Php

## 📁 **Preparing Your Project Files**

If your project uses Composer, ensure a valid [`composer.json`](/en/development-environment/supported-languages/php/composer-json.md) is at the **root** of the archive you upload. Discloud will install dependencies automatically when it detects this file.

#### ❌ **Files / Directories to Exclude**

Exclude items that are not required for runtime:

```diff
- vendor/
- node_modules/
- .git/
- tests/
- .cache/
```

📌 Use a [**`.discloudignore`**](/en/configurations/.discloudignore.md) file to exclude directories you do **not** want packed (e.g. `vendor/` if you prefer a clean install).

{% hint style="info" %}
Include `vendor/` ONLY if: you have patched libraries locally or you rely on extensions or binaries compiled during install that must match your dev environment. Otherwise excluding it keeps uploads smaller and lets Discloud perform a fresh, reproducible install.
{% endhint %}

🔗 Need to define your **main file**? See: [**Main File FAQ**](/en/faq/general-questions/what-is-the-main-file.md)

***

## 📦 **composer.json Essentials**

Minimal example:

```json
{
  "name": "example/app",
  "type": "project",
  "require": {
    "guzzlehttp/guzzle": "^7.9"
  },
  "autoload": {
    "psr-4": {
      "App\\": "src/"
    }
  },
  "scripts": {
    "start": "php -S 0.0.0.0:8080 -t public"
  }
}
```

After editing dependencies locally:

```bash
composer install
composer dump-autoload --optimize
```

More details: [`composer.json`](/en/development-environment/supported-languages/php/composer-json.md)

***

## 🌐 **Hosting Websites & APIs**

Before deploying your website or API on Discloud, ensure that you meet the following **requirements**:

{% hint style="success" %}
[Platinum plan or higher](https://discloud.com/plans) is required to host websites or APIs.
{% endhint %}

{% hint style="success" %}
[A subdomain must be created](/en/faq/general-questions/how-to-create-a-subdomain.md) before deployment.
{% endhint %}

{% hint style="danger" %}
Port `8080` is mandatory – Applications must listen on this port.
{% endhint %}

{% tabs %}
{% tab title="Built-in Server" %}
Run locally / simple deploy:

```bash
php -S 0.0.0.0:8080 -t public
```

`public/index.php` minimal:

```php
<?php
declare(strict_types=1);
echo "Hello, Discloud!";
```

{% endtab %}

{% tab title="Basic Router" %}
`public/index.php`:

```php
<?php
declare(strict_types=1);
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
header('Content-Type: application/json');
if ($path === '/status') {
    echo json_encode(['ok' => true]);
    return;
}
echo json_encode(['message' => 'Hello, Discloud!']);
```

{% endtab %}

{% tab title="Composer Script" %}
Add to `composer.json`:

```json
{
  "scripts": { "start": "php -S 0.0.0.0:8080 -t public" }
}
```

Run:

```bash
composer run-script start
```

{% endtab %}
{% endtabs %}

***

## ✍️ **Deploying Your Application**

Once your project is **configured and compressed**, you can choose one of the following **deployment methods** on Discloud:

<table data-card-size="large" data-view="cards"><thead><tr><th data-card-target data-type="content-ref"></th><th align="center"></th><th data-hidden></th><th data-hidden></th><th data-hidden></th></tr></thead><tbody><tr><td><a href="/pages/MirZiWoguOgwjGpnqp38">/pages/MirZiWoguOgwjGpnqp38</a></td><td align="center">Upload and manage your application via the web interface.</td><td></td><td></td><td></td></tr><tr><td><a href="/pages/jkiTFOhhnwJRWNqWD323">/pages/jkiTFOhhnwJRWNqWD323</a></td><td align="center">Deploy directly through Discloud’s Discord bot commands.</td><td></td><td></td><td></td></tr><tr><td><a href="/pages/Ume8fPf5afMsOH3sPYUx">/pages/Ume8fPf5afMsOH3sPYUx</a></td><td align="center">Integrate with VS Code for seamless project management.</td><td></td><td></td><td></td></tr><tr><td><a href="/pages/Obx2s2WQT8OXanw7LR2k">/pages/Obx2s2WQT8OXanw7LR2k</a></td><td align="center">Use the command-line interface for quick and efficient deployment.</td><td></td><td></td><td></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.discloud.com/en/development-environment/supported-languages/php.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
