📌 Introduction
Use PHP router in Docker container with Apache.
在 Docker container 中的 Apache 環境內使用 PHP 路由功能。
This is a simple and complete PHP routing library that supports multiple HTTP methods like GET, POST, PUT, PATCH, and DELETE.
這是一個簡單且完整的 PHP 路由套件,支持多種 HTTP 方法,如 GET、POST、PUT、PATCH 和 DELETE。
📝 Steps
1. Download PHP router from GitHub (https://github.com/phprouter/main)
2. Unzip the .zip file
3. Create a Dockerfile
and paste the following content into it
FROM php:8.0-apache
RUN a2enmod rewrite && service apache2 restart
COPY . /var/www/html/
EXPOSE 80
4. Use the following command to start the Docker container
docker build -t phprouter-test .
docker run -p 8080:80 -v $(pwd):/var/www/html/ --name phprouter-test-container phprouter-test
5. Open http://127.0.0.1:8080/
📖 Ref.
Simple and complete PHP routing library
https://github.com/phprouter/main