Shortador is a simple Url shortener written in PHP and served by a Laravel application.
An API documentation is publicly available at on https://documenter.getpostman.com/view/705705/SzzgAekC .
First of all, launch this command from a terminal (assuming the terminal is Bash or some Linux based terminal):
cp .env.example .env
this will copy the contents of the example environment file (.env.example) to the correct .env file.
At the root folder of this project there is a Dockerfile and a _docker-compose.yml _file.
Install the docker environment for your platform (https://www.docker.com/products/docker-desktop). Once Docker is installed, open a terminal and go to the project root folder (the one you will find the README file into) and launch these commands:
-
docker-compose build app
(this command will probably take a couple of minutes to complete.) -
docker-compose up -d
and all the services will start.
At this point it's time to install all the dependencies for the Laravel project, to create the env key and to launch all the DB migrations:
docker-compose exec app composer install
docker-compose exec app php artisan key:generate
docker-compose exec app php artisan migrate
Your app is up and running and you can reach it from a browser at the address: http://localhost:8000
.
It's possible to use the Postman Collection to test all the APIs.
Please mind that the Postman environment should be set accordingly with the docker-compose settings. You can find an example enviroment in the folder docker-compose/collections
. The environment is already set up with the correct docker settings.
From a terminal go to the project folder and copy the example environment to the testing environment with the following command:
cp .env.example .env.testing
From the terminal, just launch:
docker-compose exec app php artisan test --env=testing
And artisan will execute all the test located in the tests folder.