|
| 1 | + |
| 2 | +# Laravel REST API |
| 3 | + |
| 4 | +This is a basic CRUD API made with the latest version of Laravel (9.x), a popular framework made on top of PHP. The project makes use of Service Layer-Repository Pattern in order to keep the code clean and organized, custom authentication, and authorization with the help of Spatie's permission package. |
| 5 | + |
| 6 | +## Basic Usage |
| 7 | + |
| 8 | +Follow the steps below in order to start using this application. |
| 9 | + |
| 10 | +#### Create Database |
| 11 | + |
| 12 | +`$ php artisan db:create` |
| 13 | + |
| 14 | +#### Define database schema |
| 15 | + |
| 16 | +`$ php artisan migrate` |
| 17 | + |
| 18 | +#### Populate the database with data |
| 19 | + |
| 20 | +`$php artisan db:seed` |
| 21 | + |
| 22 | +#### Run the application |
| 23 | + |
| 24 | +`php artisan serve` |
| 25 | + |
| 26 | +#### Authentication credentials |
| 27 | + |
| 28 | + |
| 29 | +Password: `password` |
| 30 | + |
| 31 | +## Test Endpoints |
| 32 | + |
| 33 | +Use the following endpoints in order to test the application. |
| 34 | + |
| 35 | +#### Authentication |
| 36 | + |
| 37 | +User Register: **POST** `localhost:8000/api/register`\ |
| 38 | +User Login: **POST** `localhost:8000/api/login`\ |
| 39 | +User Logout: **POST** `localhost:8000/api/login` |
| 40 | + |
| 41 | +#### Authorization |
| 42 | + |
| 43 | +List Roles: **GET** `localhost:8000/api/roles`\ |
| 44 | +Get Role: **GET** `localhost:8000/api/roles/3`\ |
| 45 | +Add Role: **POST** `localhost:8000/api/roles`\ |
| 46 | +Update Role: **PUT** `localhost:8000/api/roles/3`\ |
| 47 | +Delete Role: **DELETE** `localhost:8000/api/roles/3`\ |
| 48 | +Search Keyword: **GET** `localhost:8000/api/roles?search=lorem` |
| 49 | + |
| 50 | +#### Articles |
| 51 | + |
| 52 | +List Articles: **GET** `localhost:8000/api/articles`\ |
| 53 | +Get Article: **GET** `localhost:8000/api/articles/3`\ |
| 54 | +Add Article: **POST** `localhost:8000/api/articles`\ |
| 55 | +Update Article: **PUT** `localhost:8000/api/articles/3`\ |
| 56 | +Delete Article: **DELETE** `localhost:8000/api/articles/3`\ |
| 57 | +Search Keyword: **GET** `localhost:8000/api/articles?search=lorem` |
| 58 | + |
| 59 | +#### Users |
| 60 | + |
| 61 | +List Users: **GET** `localhost:8000/api/users`\ |
| 62 | +Get User: **GET** `localhost:8000/api/users/3`\ |
| 63 | +Update User: **PUT** `localhost:8000/api/users/3`\ |
| 64 | +Delete User: **DELETE** `localhost:8000/api/users/3`\ |
| 65 | +Search Keyword: **GET** `localhost:8000/api/users?search=lorem` |
| 66 | + |
| 67 | +**Node:** If you're using Postman to test this API, don't forget to add HTTP Header key "Accept" with the value "application/json". |
0 commit comments