Skip to content

Hello PHP

A minimal Slim 4 web application in PHP. Multi-stage Docker build with Composer and Apache. One container, one service, no database, no cache.

Overview

Repository git@gitlab.com:appmecca-sample-apps/hello-php.git
Tech Stack PHP 8.3 / Slim 4 / Apache
Services web (port 8080)
Database None
Cache None
URL Pattern https://hello-php-web.{env}.appmecca.net

What This App Demonstrates

  • Deploying a PHP application on AppMecca
  • Multi-stage Docker build (Composer + PHP Apache)
  • Health check endpoint pattern
  • The three-step deploy process: register, build, deploy

appmecca.yaml

containers:
  - name: hello-php
    dockerfile: Dockerfile
    context: .

deploy:
  - name: web
    container: hello-php
    port: 8080
    health_check:
      path: /health

The configuration is identical in structure to any other single-container app. Apache is configured to listen on port 8080.

Step-by-Step Deployment

1. Register the app

mecca register git@gitlab.com:appmecca-sample-apps/hello-php.git -e dev

2. Build the container

mecca build trigger -e dev -g git@gitlab.com:appmecca-sample-apps/hello-php.git
Expected output
Build started: build-xxxxxxxx
Cloning repository...
Building container: hello-php
Pushing image to the private registry: hello-php/web
Build complete. Duration: 42s

3. Deploy

mecca app deploy -e dev hello-php
Expected output
Deploying hello-php to dev...
Deployment queued: deploy-xxxxxxxx
Waiting for agents...
Container started: hello-php-web
Health check passed: /health -> 200 OK
Deployment complete.

Services:
  web: https://hello-php-web.dev.appmecca.net

4. Verify

mecca app show hello-php -e dev

Test the endpoint:

curl https://hello-php-web.dev.appmecca.net/health
{"status": "healthy"}

Key Concepts

Multi-stage Docker builds for PHP

The Dockerfile uses two stages. The first stage uses the official Composer image to install PHP dependencies. The second stage uses PHP 8.3 with Apache, copying only the vendor directory from the build stage. This keeps the runtime image free of Composer and development tools.

Slim framework

Slim 4 is a micro-framework for PHP that provides routing and middleware. It follows PSR-7 (HTTP message interfaces) and PSR-15 (middleware), making it a lightweight choice for APIs and microservices.

Any language, same workflow

AppMecca does not care what language your application is written in. As long as your container listens on the declared port and responds to health checks, the deployment workflow is identical.

What's Next?