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¶
2. Build the container¶
Expected output
3. Deploy¶
Expected output
4. Verify¶
Test the endpoint:
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?¶
- Hello Flask -- see the same pattern in Python
- Hello Java -- see the same pattern in Java
- Hello Ruby -- see the same pattern in Ruby
- App with Database -- add PostgreSQL to your application