Desenvolver uma aplicação em PHP que permita o usuário a visualizar uma tabela de países e siglas (Brasil - BR), o usuário pode ordenar a lista por Nome ou Abreviação, o usuário também pode fazer o download da listagem em um arquivo CSV. É necessário também fazer o import de uma listagem disponibilizada quando rodar a migration da tabela.
Develop an application in PHP that allows the user to view a table of countries and acronyms (Brazil - BR), user can sort the list by Name or Abbreviation, user can also download the listing at a CSV file. It is also necessary to import a list available when running the table migration.
Docker Symfony 5.4 PHP 7.4 MySQL 8 NGINX Server
Before install the project you need install docker (need docker install install here)
Need up the containers, on the docker-compose.yml path, type:
docker-compose up -d --buildWith the containers upped, you can access it by command
PHP
docker exec -ti dev-php bashMysql
docker exec -ti dev-mysql bashEnter into php console by command docker exec and execute composer install.
composer installNeed create the database
php bin/console doctrine:database:createRun the migrations
php bin/console doctrine:migrations:migrateThis command will execute the command to import csv data too.
Now the application is running on 8080 port: http://localhost:8080/
The application contains a service to import a csv data. to use it you need to input a csv file in the src/Utils path with the format name,abbreviation rows. on the terminal you can use the command
php bin/console csv:importCountry filename.csvfilename.csv is the your file name.
Method to get all countries
GET /api/countries| Parâmetro | Tipo | Descrição |
|---|
Response a list of Country
"data": [
{
"id": 12,
"name": "American Samoa",
"abbreviation": "AS"
},
...
Method to create a new Country
POST /api/countries| Parâmetro | Tipo | Descrição |
|---|---|---|
name |
string |
Required, The Country name |
abbreviation |
string |
Required, The Country abbreviation |
Response
"status": "200",
"data": "Created"
Method to show a country by id
GET /api/countries/{id}| Parâmetro | Tipo | Descrição |
|---|---|---|
{id} |
int |
Required, The Country ID |
Response
"data": {
"id": 2,
"name": "United Arab Emirates",
"abbreviation": "AE"
}
Method to update a country by id
PUT /api/countries/{id}| Parâmetro | Tipo | Descrição |
|---|---|---|
{id} |
int |
Required, The Country ID |
name |
string |
The Country name |
abbreviation |
string |
The Country abbreviation |
Response
"data": "update success"
Method to delete a country by id
DELETE /api/countries/{id}| Parâmetro | Tipo | Descrição |
|---|---|---|
{id} |
int |
Required, The Country ID |
Response
"data": "delete success"
You can see a postman sample here

