Detected by
composer.json or .php files at the top of the project. The general rules are in Deploying.
Build
- PHP 8.3 with Composer 2.
- composer install --no-dev --optimize-autoloader when there is a composer.json.
- The pdo_pgsql extension is there for PostgreSQL.
Start
systemi.toml start, else a Procfile web: line, else PHP's web server on $PORT serving the top folder, so index.php and other .php files answer at their own paths.
Example
index.php
<?php
$u = parse_url(getenv('DATABASE_URL'));
$pdo = new PDO(
sprintf('pgsql:host=%s;port=%d;dbname=%s;sslmode=require', $u['host'], $u['port'], ltrim($u['path'], '/')),
$u['user'], $u['pass']
);
$rows = $pdo->query('SELECT id, total FROM orders ORDER BY id DESC LIMIT 20')->fetchAll(PDO::FETCH_ASSOC);
header('Content-Type: application/json');
echo json_encode($rows);Frameworks
| Framework | Start command or setting |
|---|---|
| Laravel | php -S 0.0.0.0:$PORT -t public public/index.php |
| Symfony | php -S 0.0.0.0:$PORT -t public public/index.php |
| Plain PHP | nothing to set |
Good to know
- Laravel: set
APP_KEY,APP_ENV=production,DB_CONNECTION=pgsqland theDB_*values as environment variables, andLOG_CHANNEL=stderrso logs show on the app page. Sessions and cache: use thedatabaseorcookiedrivers, sincestorage/is read-only at run time. - Build your front-end assets (
npm run build) before you zip; the PHP build doesn't run npm.