This is a repository to test a small application using the Slim 4, rabbitMQ, MySQL, Docker and Nginx
To be able to run this project, first you will need to have in your machine:
First the repository in your computer
- Cloning the repository
# Clone the repository
$ git clone git@github.com:Gabrielpatrola/slim-php.git
# Go to the project folder
$ cd slim-php
- Create a .env file
# Create a .env file
$ cp .env.example .env # Or copy .env.example .env (windows)
- Make changes in .env file
Open the .env
file and change the values in database variables and/or other variables if necessary.
- Starting the application
The application have everything in a docker container with Nginx, Mysql, PHP and Rabbitmq, so you will need to build the container with the command above:
$ docker-compose up -d --build
- Installing the project dependencies
$ docker exec -it slim_php composer install
- Running the database migrations
$ docker exec -it slim_php php vendor/bin/doctrine orm:schema-tool:update --force
If everything went good, you will be able to access the application in http://localhost:8080
The app have 4 endpoints:
This endpoint is used to create a new user with the payload above:
{
"name": "Test User",
"email": "test@test.com",
"password": "12345678"
}
This endpoint is used to create a new user with the payload above:
{
"email": "test@test.com",
"password": "12345678"
}
This endpoint expected a query param q
that recieves the stock symbol and also a header param called Authorization
with a token that can be got using the login route.
This endpoint returns all information for the requested stock using the Stooq API
This endpoint shows all stock requests that got succefull results. This endpoint also needs the Authorization
header
More information about the endpoints can be found in the postman collection in this link
- Sending emails
This application uses rabbitmq to send asynchronous emails, the command to execute the script is:
$ docker exec -it slim_php php consumer.php
- Testing the application
$ docker exec -it slim_php composer test