A simple local url shortener made with PHP and PostgresSQL.
Just out of boredom and to learn a bit more about PHP.
- Docker
- IDE / Text editor
- Clone the repository
- Navigate to the project folder
- Create a docker network with the following command:
docker network create --driver=bridge --subnet=172.27.0.0/16 url-shortener-network
- Create a
.env
file with the following content:
POSTGRES_HOST=172.27.0.2
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
- Run
docker compose up build
- Run
docker exec -it php bash
- Run
composer install
- Open your browser and navigate to
localhost:8080
- Enter the url you want to shorten
- Click on the shorten button
- Copy the shortened url
- Paste the shortened url in your browser to be redirected to the original url
- Done!