It's a simple API request/response CRUD
application made with Laravel.
Method | Name | API call | Response | Note |
---|---|---|---|---|
POST | User Registration | api/register | Success | Require json body |
POST | Login | api/login | Authentication token | Require json body |
POST | Add product | api/products | Created product | Require authentication key & json body |
GET | Show all products | api/products | All products | Requires nothing |
GET | Get specific product | api/products/1 | Returns product of id 1 (if exists) | Requires nothing |
PUT | Update product | api/products/1 | Returns updated product of id 1 (if exists) | Require authentication key & json body |
DELETE | Delete product | api/products/1 | Delete product of id 1 (if exists) | Require authentication key |
POST | Logout | api/logout | Logout of the system | Require authentication key |
Registration: name
, email
, password
, password_confirmation
Login: email
, password
Add products: name
, slug
, description
, price
Update products: name
, description
, price
[Note: not all the field is required here]
Download and install the Postman desktop application. Create a new collection then create a new global variable token
for authorization. Initialize the variable with the token from the response of login. Now navigate to the API request window, search for Authorization
tab; Select type Bearer Token
and set the token
in the Token field. [NOTE: global variable token
must be reinitialized with the new token value from the response of login every time after logout.]
- Set Headers to accept
application/json
and usex-www-form-urlencoded
where needed for convenience.
Your machine must have composer, php, xampp, git, node installed.
https://github.com/rezabtuhin/laracrud.git
composer install
npm install
cp .env.example .env
Set up the database in the .env
file and your MySQL
server and configurations. Then run-
php artisan key:generate
php artisan migrate
php artisan serve
Sample postman config file: Download here.
Good luck ๐