— PHP, Laravel, Authenticate, JSON, MySQL, Database — 1 min read
Authentication in Laravel app can also be done if all the user data in stored in JSON file and not in MySQL, PostgreSQL etc.
# Real World Use Case
# Versions, Links and References
Though it is very unlikely that this way of authentication will be used in any real world app, but this implementation can be used to implement custom auth provider which can use Redis, Lightweight Directory Access Protocol (LDAP) etc.
Still there might be some use cases:
If the users info are stored in separate DB and in case if it goes down, its exported backup file can be used here.
If initially the user info (in some cases) are only stored in excel sheet (or json file like here) and then it is required to authenticate the app on the top of that data, this might be helpful.
Using production data in locally running app: Production database have lot of records, and few of them are exported. That exported data can be used in locally running apps.
Laravel: 5.5 (also much relavant to versions till 8.X)
How to implement:
Official Laravel docs explains it amazingly.
https://laravel.com/docs/5.5/authentication#adding-custom-user-providers
Implementation repository - Data stored in JSON file: https://github.com/SOHELAHMED7/json_file_user_provider