Laravel Sanctum Laravel Basic authorization process for user API registration and login with validations and response token.
- PHP Version => 7.4 or higher
- Laravel Version => 8 or higher
- MySQL Version => 5.7 or higher
- Sanctum implement into Laravel Project
- Login api : http://127.0.0.1:8000/api/login
- Login Fields
- Email : [ Validation Rules : Valid Unique Email, Required ]
- Password : [ Validation Rules : Strong Password, Required ]
- Register api : http://127.0.0.1:8000/api/register
- Register Fields
- Name : [ Validation Rules : Only String allowed, Max 100 length, Required ]
- Email : [ Validation Rules : Valid Unique Email, Required ]
- Password : [ Validation Rules : Strong Password, Required ]
- Logout api : http://127.0.0.1:8000/api/logout
- For logout pass current logedIn token as Header Bearer
- Refresh api : http://127.0.0.1:8000/api/refresh
- Refresh token on basis of old token verification and generate new token as Header Bearer
- Profile api : http://127.0.0.1:8000/api/profile
- Get existing loggedin user full details as Header Bearer
- Change Password api : http://127.0.0.1:8000/api/change-password
- UpdatePassword on basis of Old password, new Password and new password confirmation as Header Bearer
- Update Password with Token : 3 Steps apis
- Forget Password api : http://127.0.0.1:8000/api/forget-password
- send email to change Password token
- Verify Token api : http://127.0.0.1:8000/api/password/reset/{token?}/{email?}
- token Verification
- Update Password By Token api : http://127.0.0.1:8000/api/update-password
- updatePasswordByToken on basis of Token and Password
- Use Laravel's migration scripts for database schema and tables related to further all operations
- Use Laravel's factory and seeders for sample dummy data creations where required
- Use Laravel's validation using Request classes where required
- Use Laravel's Eloquent and Relationships in models where required
- Use camel case for function name and variable name. E.g getProductDetails() , $categoryDetails
- Comment on the above function with short details of that function use or purpose of function creation.
- Reuse the common codes using some helper class functions etc
- Remove unnecessary code and debug points that are not needed
- Avoid unnecessary loops if not required
- Avoid unnecessary variable creations
- Use PHP design patterns where required Design Patterns
- Normalize database tables where required Database Normalization
- Optimize database tables
- Avoid MySQL joins queries if not required
- Avoid MySQL sub queries if it does not require
- For more information, please read the document Code Standard
- https://laravel.com/docs/master/sanctum#main-content
- https://www.positronx.io/build-secure-php-rest-api-in-laravel-with-sanctum-auth/
- https://www.itsolutionstuff.com/post/laravel-9-rest-api-authentication-using-sanctum-tutorialexample.html
- https://www.youtube.com/watch?v=P2dfXpUHy6U&t=5s
- https://www.youtube.com/watch?v=YuIbOzvS-Jk
- KEY : SANCTUM