This is a containerized version of the PHP sample application with:
- Dependency Injection
- Apache routing
- Composer (aka: Not reinventing the wheel)
- Docker containers for both web application and database
- Unix-like operating systems
- Apache
- MariaDB/MySQL
- PHP >= 7.1
- Command line tools
make
&wget
- Docker
- Docker Compose
-
Clone this repository:
git clone https://github.com/YOUR_GITHUB_USERNAME/php-sample-application.git cd php-sample-application
-
Launch the application with Docker Compose:
docker-compose up -d
-
Access the application at http://localhost:8080/
Pre-built Docker images are available on Docker Hub:
- Web Application: andresdockerdev/php-sample-web
- Database: andresdockerdev/php-sample-db
To use these images directly:
docker-compose -f docker-compose.prod.yml up -d
Variable | Description | Default |
---|---|---|
DB_HOST | Database hostname | db |
DB_NAME | Database name | sample |
DB_USER | Database username | sampleuser |
DB_PASSWORD | Database password | samplepass |
Variable | Description | Default |
---|---|---|
MYSQL_ROOT_PASSWORD | Root password | rootpassword |
MYSQL_DATABASE | Database name | sample |
MYSQL_USER | Username | sampleuser |
MYSQL_PASSWORD | Password | samplepass |
If you encounter database connection issues:
- Ensure the database container is running:
docker ps
- Check database logs:
docker logs php-sample-db
- Verify environment variables match between services
- Check web server logs:
docker logs php-sample-web
- Ensure ports are correctly mapped in docker-compose.yml