This project sets up two PHP microservices that can communicate with each other using Docker.
- Service 1: This service makes a request to Service 2 and displays the response.
- Service 2: This service responds with a simple message.
php-microservices
├── service1
│ ├── src
│ │ └── index.php
│ └── Dockerfile
├── service2
│ ├── src
│ │ └── index.php
│ └── Dockerfile
├── docker-compose.yml
└── README.md
- Docker
- Docker Compose
-
Navigate to the project directory:
cd php-microservices
-
Build and start the services using Docker Compose:
docker-compose up --build
-
Access Service 1 in your browser:
http://localhost:8001
To stop the services, you can use:
docker-compose down
Service 1 communicates with Service 2 using the internal Docker network. The URL used in Service 1 with PHP to access Service 2 is http://service2:8002
.
This setup allows for easy development and testing of microservices using PHP and Docker.