PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Maniruzzaman Akash   Advanced Laravel CRUD API   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Advanced Laravel CRUD API
Implement API that provide CRUD operations
Author: By
Last change:
Date: 1 year ago
Size: 3,423 bytes
 

Contents

Class file image Download

Laravel CRUD API with Auth

Basic Laravel CRUD API application included with Authentication Module & Product Module. It's included with JWT authentication and Swagger API format.

Language & Framework Used:

  1. PHP-8
  2. Laravel-9

Older Versions (if Needed):

  1. Laravel 8.x - https://github.com/ManiruzzamanAkash/Laravel-Advanced-CRUD-API/releases/tag/vLaravel8.x

Architecture Used:

  1. Laravel 9.x
  2. Interface-Repository Pattern
  3. Model Based Eloquent Query
  4. Swagger API Documentation - https://github.com/DarkaOnLine/L5-Swagger
  5. JWT Auth - https://github.com/tymondesigns/jwt-auth
  6. PHP Unit Testing - Some basic unit testing added.

API List:

Authentication Module
  1. [x] Register User API with Token
  2. [x] Login API with Token
  3. [x] Authenticated User Profile
  4. [x] Refresh Data
  5. [x] Logout
Product Module
  1. [x] Product List
  2. [x] Product List [Public]
  3. [x] Create Product
  4. [x] Edit Product
  5. [x] View Product
  6. [x] Delete Product

How to Run:

  1. Clone Project -
git clone https://github.com/ManiruzzamanAkash/Laravel-Basic-CRUD-API.git
  1. Go to the project drectory by `cd Laravel-Basic-CRUD-API` & Run the
  2. Create `.env` file & Copy `.env.example` file to `.env` file
  3. Create a database called - `laravel_basic_crud`.
  4. Install composer packages - `composer install`.
  5. Now migrate and seed database to complete whole project setup by running this-
    php artisan migrate:refresh --seed
    
    It will create `21` Users and `103` Dummy Products.
  6. Generate Swagger API
    php artisan l5-swagger:generate
    
  7. Run the server -
    php artisan serve
    
  8. Open Browser - http://127.0.0.1:8000 & go to API Documentation - http://127.0.0.1:8000/api/documentation
  9. You'll see a Swagger Panel.

Procedure

  1. First Login with the given credential or any other user credential
  2. Set bearer token to Swagger Header or Post Header as Authentication
  3. Hit Any API, You can also hit any API, before authorization header data set to see the effects.

Demo

API List Views:

<img src="https://i.ibb.co/gV1Yn9Z/1-Swagger-API-Demo.png" alt="1-Swagger-API-Demo" border="0">

Login in Swagger with Given Data:

<img src="https://i.ibb.co/5vrXkgN/2-API-Login1.png" alt="2-API-Login1" border="0">

Get token After Successful Login:

<img src="https://i.ibb.co/cQ37n9t/3-API-Login2-Response.png" alt="3-API-Login2-Response" border="0">

Set token in Swagger Header:

<img src="https://i.ibb.co/m8xQZ4T/Screenshot-2022-07-12-at-8-37-47-AM.png" alt="4-API-Swagger-Set-Bearer-Token" border="0">

Or, Set token in Postman Header as Authorization:

<img src="https://i.ibb.co/7p8Y3Yz/Postman-Product-List-API-with-Authenticated-Token.png" alt="Postman-Product-List-API-with-Authenticated-Token" border="0">

Hit Any API Route in Swagger:

<img src="https://i.ibb.co/VSWbXq9/5-API-Swaagger-Public-Product-List-View.png" alt="5-API-Swaagger-Public-Product-List-View" border="0">

Image Upload throw Postman:

<img src="https://i.ibb.co/VBkMBBp/Postman-Store-Product-with-File-Upload.png" alt="Postman-Store-Product-with-File-Upload" border="0">

Test

  1. Test with Postman - https://www.getpostman.com/collections/5642915d135f376b84af [Click to open with post man]
  2. Test with Swagger.
  3. Swagger Limitation: Image can not be uploaded throw Swagger, it can be uploaded throw Postman.