Php
Complete guide to host PHP applications on Discloud.
📁 Preparing Your Project Files
If your project uses Composer, ensure a valid composer.json 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:
- vendor/
- node_modules/
- .git/
- tests/
- .cache/📌 Use a .discloudignore file to exclude directories you do not want packed (e.g. vendor/ if you prefer a clean install).
🔗 Need to define your main file? See: Main File FAQ
📦 composer.json Essentials
Minimal example:
{
"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:
composer install
composer dump-autoload --optimizeMore details: composer.json
🌐 Hosting Websites & APIs
Before deploying your website or API on Discloud, ensure that you meet the following requirements:
Platinum plan or higher is required to host websites or APIs.
A subdomain must be created before deployment.
Port 8080 is mandatory – Applications must listen on this port.
Run locally / simple deploy:
php -S 0.0.0.0:8080 -t publicpublic/index.php minimal:
<?php
declare(strict_types=1);
echo "Hello, Discloud!";public/index.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!']);Add to composer.json:
{
"scripts": { "start": "php -S 0.0.0.0:8080 -t public" }
}Run:
composer run-script start✍️ Deploying Your Application
Once your project is configured and compressed, you can choose one of the following deployment methods on Discloud:
Last updated