"Hello World" Examples PHP Laravel

Laravel showcase

A Laravel application connected to PostgreSQL, Valkey (Redis-compatible), S3-compatible object storage, and Meilisearch, running on Zerops with six ready-made environment configurations β€” from AI agent and remote development to stage and highly-available production.

Lightweight project core
Single dedicated container with balancers (L3/L7), logger and statistics services
app
PHP+Nginx

Containers

1Shared Core

0.5 GBRAM

GBDisk (SSD)

 GitHub repo
worker
PHP+Nginx

Containers

1Shared Core

0.5 GBRAM

GBDisk (SSD)

 GitHub repo
db:5432,:6432
PostgreSQL

Container

1Shared Core

0.25 GBRAM

GBDisk (SSD)

redis:6379,:6380
Valkey

Container

1Shared Core

0.25 GBRAM

GBDisk (SSD)

storage
Object storage

External

GBSize

search:7700
Meilisearch

Container

1Shared Core

0.25 GBRAM

GBDisk (SSD)

7Shared Cores

2.75 GBRAM

GBDisk (SSD)

GBObject storage

$13.16

Per month for
Resources cost
add
FreePer month for
Lightweight pkg.

After deploying one of the environments and getting to know Zerops, you have two paths forward. 1 Clone our GitHub repositories and use the whole recipe as a template, or if you already have an existing application on a similar stack, 2 integrate the recipe setup with your application.

or

Taking ownership of the Small Production environment

πŸ“¦ Clone the template repositories

Fork or clone the following to your local machine or GitHub account:

1. Find your service name

Many commands and configurations need the exact name of your service. You can find it in the Zerops Dashboard.

  • Open your project in the Zerops Dashboard.
  • In the project overview, find the service you want to manage.
  • Use this exact name whenever a command or pipeline configuration asks for <service-name>.
Zerops GUI: Locating the Service Name

2. Configure deployment pipeline

Go to Service Settings > Pipelines & CI/CD Settings in the Zerops Dashboard and connect your repository.

For production, use a trigger on new tags. This keeps deployments intentional and tied to a specific version. You can also add a regex filter, such as ^v[0-9]+\.[0-9]+\.[0-9]+$, if you want to allow only semantic version tags.

Zerops GUI: Triggers

Alternatively, add zcli push to your existing CI/CD pipeline if you want full control over when deployments happen.

Learn more about pipeline triggers: https://docs.zerops.io/features/pipeline

3. Deploy to production

Create and push a new Git tag to deploy a specific version of your app:

bash
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0

lightbulb Tip

Open the pipeline detail in the Zerops Dashboard to check the build progress and verify that all steps finish successfully.

4. Configure autoscaling

Review the autoscaling settings for your runtime services and databases in Service Settings > Automatic Scaling Configuration in the Zerops Dashboard.

Zerops GUI: Autoscaling configuration

The most important settings are:

yaml
verticalAutoscaling:
  minRam: 1
  minFreeRamGB: 0.5
  minFreeRamPercent: 20

report Caution

Pay attention to minFreeRamGB. This value tells Zerops when to scale RAM vertically. Adjust it based on your app’s real memory needs. RAM scales up immediately, while CPU scales after two consecutive measurements below the threshold.

[!TIP] Run a quick stress test with a tool like hey before real users arrive. This helps you see how your app behaves under load and tune the autoscaling settings.

5. Set up your domain

To send real traffic to your app, configure public HTTP access in Service Settings > Public Access & Internal Ports in the Zerops Dashboard.

Add your custom domain and point your DNS records to the Zerops IPs shown in the dashboard:

Zerops GUI: Public access and custom domain
text
Type   Name          Content          TTL
A      example.com   <zerops-ipv4>    Auto
AAAA   example.com   <project-ipv6>   Auto

For wildcard domains, add a CNAME record for SSL validation.

Check the public access documentation: https://docs.zerops.io/features/access

lightbulb Tip

When changing DNS records for production, start with a low TTL value. Make sure SSL certificates are active before you disable the fallback Zerops subdomain.

Once everything works, you can disable the Zerops subdomain so all traffic goes through your custom domain.


πŸŽ‰ You are good to go!

Your application is live in production and the core setup is complete.

The following sections are optional. They cover extra production features such as log forwarding, backups, and diagnostic access. You can stop here and come back later when you need them.


6. Set up log forwarding (Optional)

To send logs to an external service, go to Project Settings > Log Forwarding & Logs Overview in the Zerops Dashboard.

You can forward logs to services like Better Stack, Papertrail, or your own self-hosted solution.

Learn more about log forwarding: https://docs.zerops.io/references/logging

7. Configure database backups (Optional)

Manage automated encrypted backups in Service Settings > Backups in the Zerops Dashboard.

By default, backups run daily between 00:00 and 01:00 UTC.

Before a major deployment, create a manual protected backup:

bash
zcli backup create <db-service> --tags pre-deploy,protected

Read the backup documentation for more options: https://docs.zerops.io/features/backup

8. Set up diagnostic access (Optional)

Use zCLI and VPN access when you need to inspect or maintain services directly.

For runtime services:

bash
zcli vpn up
ssh <service-name>.zerops

For databases, connect through the VPN to reach the project’s private network, or set up secure direct IP access for your database admin tools.

Check the VPN documentation: https://docs.zerops.io/references/cli/commands#vpn-up

🏁 What's next?

See how the applications were integrated with Zerops

Even when you use this recipe as a template, it's good to have an idea of what steps were taken to best integrate the apps into Zerops.

Deploy environments for the rest of the development lifecycle

One environment rarely tells the full story β€” deploy environments for other stages of development to see how they work on Zerops.

Knowledge Base

PHP+Nginx Β· app, worker
Gotchas

PHP+Nginxappworker

zerops-recipe-apps/laravel-showcase-app

Gotchas

  • No .env file β€” Zerops injects environment variables as OS env vars. Creating a .env file with empty values shadows the OS vars, causing env() to return null for every key that appears in .env even if the platform has a value set.
  • Cache commands in initCommands, not buildCommands β€” config:cache, route:cache, and view:cache bake absolute paths into their cached files. The build container runs at /build/source/ while the runtime serves from /var/www/. Caching during build produces paths like /build/source/storage/... that crash at runtime with "directory not found."
  • APP_KEY is project-level β€” Laravel's encryption key must be shared across all services that read the same database (app + worker both need the same key for sessions and encrypted columns). Set it once at project level in Zerops; do not add it per-service or in zerops.yaml envVariables.
  • PDO PostgreSQL extension β€” The php-nginx base image includes pdo_pgsql out of the box. No prepareCommands or apk add needed for PostgreSQL connectivity.
  • Predis over phpredis β€” The php-nginx base image does not include the phpredis C extension. Use the predis/predis Composer package and set REDIS_CLIENT=predis to avoid "class Redis not found" errors.
  • Object storage requires path-style β€” Zerops object storage uses MinIO, which requires AWS_USE_PATH_STYLE_ENDPOINT=true. Without it, the SDK attempts virtual-hosted bucket URLs that MinIO cannot resolve.
  • Vite manifest missing on dev after fresh deploy β€” the dev setup intentionally omits npm run build from buildCommands so the HMR workflow (npm run dev via SSH) stays fast. Any view rendering @vite(...) therefore 500s with Vite manifest not found at: /var/www/public/build/manifest.json on the first request after a zerops_deploy. Fix: run ssh appdev 'cd /var/www && npm run build' once after the deploy and before zerops_verify β€” SSHFS propagates the manifest into the container without a redeploy. For iterative work, ssh appdev 'cd /var/www && nohup npm run dev > /tmp/vite.log 2>&1 &' drops public/build/hot and Laravel routes asset URLs to the dev server. Do NOT add npm run build to dev buildCommands β€” it adds ~20–30 s to every zcli push and defeats the HMR-first design.