The idea of this project was to create a program that can be used by a hospital. In it, different nurses can register, log in, or perform various interactions with the database generated by Doctrine. It includes a set of basic functions that interact with the database through Doctrine:
| Function | Description |
|---|---|
| getAllNurses | Connects to the database and displays all nurse data as a JSON response |
| nurseLogin | Allows a nurse to attempt login using their credentials stored in the database |
| findByName | Searches for a nurse in the database by name and returns all their details |
These were the first ones to be developed. Once finished, we implemented CRUD technology, adding five more functions:
| Function | Description |
|---|---|
| Index | Similar to "getAllNurses"; retrieves and displays all nurse records |
| New | Allows you to add a new nurse to the database |
| Show | Searches for a nurse by their ID and displays their information |
| Edit | Enables modification of any nurse's data in the database |
| Delete | Deletes a nurse from the database using their ID |
To install the program click the green "Code" button you can either use the download ZIP method or cloning using the URL
Click the "download ZIP option and extract it. Open the folder using Visual Studio Code which contains all the files
Our program requires composer in order to work
Execute the following command using either the VSC terminal or Windows Power Shell
Note: This requires composer to be installed previously
Also make sure to be executing the command at the folder which contains all the files
composer installDoctrine is a library that allows connection with databases, which we used it to manage our CRUD and its installation is required in order to make our code functional Execute the following command using either VSC terminal or Windows Power Shell
composer require symfony/orm-pack.env files contains the link to the connection of your database, make sure to uncomment the database version that you are using and change to your own values
Execute the following command to create a database
php bin/console doctrine:database:createExecute the following command to create the table and its fields
php bin/console doctrine:migrations:migrateAfter this step you can add as many nurses as you like.
Our project has not front-end, so we need a software which sends requests, in our case, we used Postman.
You have two ways to download Postman
1: As a software, for this installation check Postman oficial site
2: As a VSC extension search "Postman.postman-for-vscode" at VSC extensions and it will show you
After the installation you are asked to create an account
Run the Symfony development server to access the application:
symfony server:start
The application should now be accessible at `http://localhost:8000`.
The application includes key functionalities accessible through API endpoints. Here are examples of the main functionalities:
Endpoint: /api/nurses
Method: GET
Description: Returns a list of all nurses in JSON format.
Example Request:
curl -X GET http://localhost:8000/api/nurses
Endpoint: /api/nurses/login
Method: POST
Description: Allows a nurse to log in with email and password.
Example Request:
curl -X POST http://localhost:8000/api/nurses/login -d "email=nurse@example.com&password=yourpassword"
Endpoint: /api/nurses/find/{name}
Method: GET
Description: Searches for a nurse by name and returns their details.
Example Request:
curl -X GET http://localhost:8000/api/nurses/find/JaneDoe
Endpoint: /api/nurses/new
Method: POST
Description: Creates a new nurse with the provided details.
Example Request:
curl -X POST http://localhost:8000/api/nurses/new -d "name=Jane Doe&email=jane.doe@example.com&password=123456"
Endpoint: /api/nurses/{id}/edit
Method: PUT
Description: Updates the information of a specific nurse by ID.
Example Request:
curl -X PUT http://localhost:8000/api/nurses/1/edit -d "email=newemail@example.com"
Endpoint: /api/nurses/{id}/delete
Method: DELETE
Description: Deletes a nurse record by ID.
Example Request:
curl -X DELETE http://localhost:8000/api/nurses/1/delete
- Ensure the Symfony server is running before making API requests.