This repository contains a PHP script that logs all incoming HTTP requests along with their headers and request data ($_REQUEST). This can be useful for debugging or monitoring purposes in web applications.
To use this request logger, follow these steps:
-
Clone this repository to your local machine:
git clone https://github.com/tshenolo/docker-php-request-logger.git
-
Navigate into the cloned directory:
cd docker-php-request-logger
-
Build the Docker image using the provided Dockerfile:
docker build -t request-logger .
-
Run the Docker container:
docker run -d -p 8080:80 request-logger
This will start the PHP script inside a Docker container accessible at http://localhost:8080/.
-
View logs:
docker logs <container_id_or_name>
-
Access the container:
docker exec -it <container_id_or_name> /bin/bash
-
Stop container:
docker stop <container_id_or_name>
-
Remove image
docker rmi -f <image_id_or_name>
Once the Docker container is running, you can send HTTP requests to the server, and the script will log them along with the headers and request data. The logs can be viewed using the command: docker logs <container_id_or_name>.
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer my_token" \
http://localhost:8080/index.php?key1=value1&key2=value2
curl -X POST \
-H "Content-Type: application/json" \
-d '{"key1": "value1", "key2": "value2"}' \
http://localhost:8080/index.php
If you have suggestions or improvements, feel free to open an issue or create a pull request. Contributions are welcome!
This project is licensed under the MIT License - see the LICENSE file for details.
- ⭐ Give this repo a ⭐ star ⭐ at the top of the page
- 🐦 Follow me on twitter twitter
- 📺 Subscribe to my Youtube channel