Stacks
PHP
Deploy plain PHP sites and Composer projects, with a MySQL database.
What we detect
A composer.json (without artisan) makes it a PHP app. A site with an index.php or public/index.php works too.
- Install:
composer installwhen there's acomposer.json. - Serve: PHP-FPM behind nginx, on port 8080. Your
public/folder is the web root when you have one, otherwise the app's root.
Database
Link a MySQL or MariaDB database. Plain PDO code can read DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and DB_PASSWORD, or the short aliases DB_NAME, DB_USER and DB_PASS:
<?php
$pdo = new PDO(
sprintf('mysql:host=%s;port=%s;dbname=%s;charset=utf8mb4', getenv('DB_HOST'), getenv('DB_PORT'), getenv('DB_DATABASE')),
getenv('DB_USERNAME'),
getenv('DB_PASSWORD'),
);Don't hard-code localhost
Old code often connects to localhost with a fixed password. On DockHosting the database is another server: read the variables above instead.
Uploads
Files your app writes are lost on the next deploy unless they're in persistent storage (paid plans). Turn on Persistent storage in the project's Settings and give it the folder your app writes to, for example /app/uploads.
