Docs menu
Getting started with PHP
Deploy a minimal PHP app to Primcloud end-to-end using a sample repo, in about five minutes.
On this page
This guide walks through deploying a small PHP app to Primcloud. You'll fork a sample repo, import it, watch the build, and reach the deployed app at a *.primcloud.app URL. Takes about five minutes.
Before you start#
You'll need:
- A Primcloud account. Standard accounts are free to create; compute is metered by the minute once you deploy, from around $5/mo for the smallest app.
- A git provider connected to your account with access to at least one repo.
- Optional: PHP 8.4 or newer and Composer installed locally, if you want to run the sample or make changes before deploying.
The sample app#
For this guide, use Heroku's heroku/php-getting-started repo. It's a minimal Slim 4 app that builds cleanly on the Primcloud Runtime with no changes. Fork it into an account your connected provider can see, so Primcloud can pull from it.
The sample ships two files that matter for the build:
{
"require": {
"php": "^8.4",
"slim/slim": "^4.0"
}
}
web: heroku-php-apache2 web/
The composer.json pins PHP to the 8.4 line and lists the app's dependencies. The Procfile starts Apache with PHP-FPM and serves from the web/ subdirectory.
1. Create the application#
From the Primcloud dashboard, hit Import Git Repository on the applications list. The import wizard walks you through three quick steps:
- Pick a repository: select your fork of
php-getting-started. - Configure the deployment:
- Branch:
main(the fork's default). - Region: US East (NYC).
- Branch:
- Review and create: Primcloud auto-provisions the app's primary
*.primcloud.appsubdomain on the production environment.
2. Deploy#
The first deployment kicks off automatically when the app is created. Watch it stream in the Deployments tab:
- Detection. Primcloud sees the
composer.jsonat the repo root and picks the PHP toolchain. - Build. The build installs the PHP runtime and Composer, then runs
composer install --no-dev --optimize-autoloader --prefer-distagainst your lockfile. - Release. Primcloud starts the
webprocess from yourProcfile, launching Apache with PHP-FPM against theweb/document root.
When the deployment status flips to Release Succeeded, the app is live.
3. Reach the app#
The application dashboard shows the assigned *.primcloud.app URL in the header. Click it, and the sample's homepage loads.
If it doesn't come up:
- Deployments: the build log has the raw output from Composer and the PHP build.
- Logs: runtime output from your app streams there, including PHP-FPM startup errors and any uncaught exceptions.
- Confirm the document root in your
Procfilematches the directory that containsindex.php. The Slim sample serves fromweb/; a Laravel app serves frompublic/. - Confirm the launcher binds to the port in
$PORT. Bothheroku-php-apache2andheroku-php-nginxdo this automatically; a hand-rolled entrypoint would need to read$PORTitself.
Where to go next#
- Deploying a different PHP app: PHP on Primcloud for detection, Composer install behavior, and web server selection.
- Pinning to a specific PHP version: Runtime versions.
- Using a private Composer repository: Package managers.
- Switching from Apache to nginx, or adding a custom nginx/Apache config: Customizing the build.
- Deploying a Laravel app: Deploying Laravel.
- Something breaking: Troubleshooting PHP.