"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. Identify Your Service Name

Many commands and configurations require your specific service name. You can find this easily in the interface.

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

2. Configure CI/CD Pipeline for Tag-Based Deployments

Go to Service Settings > Pipelines & CI/CD Settings in the Zerops Dashboard and connect your repository with a trigger on new tags. This makes your production deployments intentional and safely versioned. You can also add a regex filter (like ^v[0-9]+\.[0-9]+\.[0-9]+$) for strict semantic versioning.

Zerops GUI: Triggers

Alternatively, integrate zcli push into your existing CI/CD pipeline for maximum control. Learn more about pipeline triggers.

3. Deploy to Production

Using tags gives you full control over exactly which version goes live. Publish a new tag in your repository (like a GitHub Release) to trigger a production deployment:

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

lightbulb Tip

Explore the pipeline detail in the Zerops Dashboard to check build durations and verify all steps complete successfully before the app goes live.

4. Configure Autoscaling

Review and tune the autoscaling options for your databases and runtime applications in Service Settings > Automatic Scaling Configuration within the Zerops Dashboard. Here are the key parameters:

Zerops GUI: Triggers
yaml
verticalAutoscaling:
  minRam: 1
  minFreeRamGB: 0.5
  minFreeRamPercent: 20

report Caution

Keep an eye on the minFreeRamGB setting (default 0.125 GB). This threshold tells Zerops when to scale vertically. Adjust it based on your app's actual needs to keep things running smoothly and avoid memory limits. RAM scales up immediately, while CPU scales after two consecutive measurements below the threshold.

[!TIP] Run a quick stress test using tools like hey on your HTTP apps. Seeing how your app behaves under load helps you fine-tune these parameters before real users arrive.

5. Enable Custom Domain Access

To route real traffic to your app, configure public HTTP access in Service Settings > Public Access & Internal Ports from the Zerops Dashboard. Add your custom domain and point your DNS records to the provided Zerops IPs:

Zerops GUI: Triggers
text
Type   Name          Content          TTL
A      example.com   <zerops-ipv4>    Auto
AAAA   example.com   <project-ipv6>   Auto

For wildcard domains, add a CNAME for SSL validation. Check the public access documentation for full details.

lightbulb Tip

When changing DNS records for production, it is good practice to use low TTL values initially. Make sure SSL certificates are active before you turn off the fallback access.

Once everything is working perfectly, you can disable the Zerops subdomain access so all traffic flows through your official custom domain.


๐ŸŽ‰ You are good to go!

Your application is now live and running in production. You have successfully completed the core setup.

The following sections are entirely optional. They cover extra features like notifications, advanced logging, and backups. You can safely stop reading here and come back later whenever you want to level up your environment.


6. Enable Log Forwarding (Optional)

For better observability, head to Project Settings > Log Forwarding & Logs Overview inside the Zerops Dashboard. You can easily forward your logs to services like Better Stack, Papertrail, or self-hosted solutions. Learn more about log forwarding.

7. Configure Database Backups (Optional)

Manage your automated encrypted backups in Service Settings > Backups on the Zerops Dashboard. By default, backups run daily (00:00-01:00 UTC) with a solid retention policy.

It is always a good idea to create a manual, protected backup before a major deployment:

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

Read the backup documentation for more options.

8. Set Up Diagnostic Access (Optional)

Install zCLI and set up secure access for maintenance:

For runtime services:

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

For databases: Connect via 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 for instructions.

๐Ÿ 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+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.