Skip to main content

Prerequisites

Deploy from Recipe

The fastest way to get started is to deploy our ready-made PHP example:
1

Import the Project

Log in to Zerops GUI and click Import a project.
2

Paste the Configuration

Use this YAML configuration:
project:
  name: my-first-php-app
services:
  - hostname: app
    type: [email protected]
    minContainers: 1
    maxContainers: 3
    buildFromGit: https://github.com/zeropsio/recipe-php-hello-world@main
    enableSubdomainAccess: true
3

Wait for Deployment

Click Import project and wait for the build and deployment to complete.
4

Access Your App

Once deployed, find your subdomain URL in the IP Addresses & Public Routing Overview.It will look like: https://app-{project-id}-8080.prg1.zerops.appVisit the URL to see “Hello, World!”

Deploy Your Own PHP Application

Step 1: Add zerops.yaml

Create a zerops.yaml file in your repository root:
zerops:
  - setup: app
    build:
      base: [email protected]
      buildCommands:
        - composer install --optimize-autoloader --no-dev
      deployFiles:
        - vendor
        - public
        - src
      cache: vendor
    
    run:
      base: [email protected]
      documentRoot: public

Step 2: Configure Your Service

Create a service using Zerops CLI or GUI:
Create a description.yaml:
project:
  name: my-php-app
services:
  - hostname: app
    type: [email protected]
    minContainers: 1
    maxContainers: 6
Import the project:
zcli project project-import description.yaml

Step 3: Deploy Your Code

Connect your GitHub repository in the Zerops GUI:
  1. Go to your service detail
  2. Click Build & Deploy Pipeline
  3. Select GitHub or GitLab
  4. Choose your repository and branch
  5. Click Deploy

Common Configurations

Laravel Application

zerops:
  - setup: app
    build:
      base: [email protected]
      buildCommands:
        - composer install --optimize-autoloader --no-dev
        - php artisan config:cache
        - php artisan route:cache
        - php artisan view:cache
      deployFiles:
        - vendor
        - bootstrap
        - public
        - resources
        - routes
        - storage
        - app
        - config
        - artisan
      cache: vendor
    
    run:
      base: [email protected]
      documentRoot: public
      initCommands:
        - php artisan migrate --force

WordPress Site

zerops:
  - setup: app
    build:
      base: [email protected]
      buildCommands:
        - composer install
      deployFiles: .
    
    run:
      base: [email protected]
      documentRoot: .
      envVariables:
        PHP_INI_upload_max_filesize: 20M
        PHP_INI_post_max_size: 20M

Custom PHP API

zerops:
  - setup: api
    build:
      base: [email protected]
      buildCommands:
        - composer install --no-dev
      deployFiles:
        - vendor
        - src
        - public/index.php
    
    run:
      base: [email protected]
      documentRoot: public
      ports:
        - port: 8080
          httpSupport: true

Adding a Database

Extend your description.yaml to include a database:
project:
  name: my-php-app
services:
  - hostname: app
    type: [email protected]
    minContainers: 1
    maxContainers: 6
  
  - hostname: db
    type: postgresql@16
    mode: NON_HA
Connect to the database using the hostname:
$host = 'db';
$dbname = getenv('DB_NAME');
$user = getenv('DB_USER');
$password = getenv('DB_PASSWORD');

$dsn = "pgsql:host=$host;dbname=$dbname";
$pdo = new PDO($dsn, $user, $password);

Environment Variables

Set environment variables in zerops.yaml:
run:
  envVariables:
    APP_ENV: production
    APP_DEBUG: false
Or add secret variables through the Zerops GUI:
  1. Go to service detail
  2. Click Environment Variables
  3. Add your secrets (database passwords, API keys, etc.)

Customize PHP Configuration

Adjust PHP settings via environment variables:
run:
  envVariables:
    PHP_INI_memory_limit: 256M
    PHP_INI_max_execution_time: 60
    PHP_INI_post_max_size: 20M
    PHP_FPM_PM_MAX_CHILDREN: 30

Troubleshooting

Make sure your composer.json and composer.lock are committed to your repository.Try running with verbose output:
buildCommands:
  - composer install --verbose
Check your documentRoot setting. For Laravel/Symfony, it should be:
run:
  documentRoot: public
Ensure your build.base and run.base use the same PHP version:
build:
  base: [email protected]
run:
  base: [email protected]

Next Steps

Runtime Overview

Learn about PHP runtime features

Environment Variables

Manage secrets and configuration

Scaling

Configure auto-scaling

Custom Domains

Add your own domain

Build docs developers (and LLMs) love