Laravel API help
-
I have a set of currently working routes on Laravel. I want to make RESTFUL API for scaling for android front end. How do I convert my existing web.php into api.php?
As a example what are the routes should be be there in api.php for laravel default AUTH.
I just want to call my existing routes by POSTMAN -
If you need to secure login for your mobile app then you have to use Laravel / Passport.
What is Laravel Passport?
APIs typically use tokens to authenticate users and do not maintain session state between requests. Laravel makes API authentication a breeze using Laravel Passport, which provides a full OAuth2 server implementation for your Laravel application in a matter of minutes. learn more
What are the routes should be there in api.php
- Login
- Register
- Other Routes on your application
ex : post/topic, get/topic, edit/topic
How do I convert my existing web.php into api.php
Simply get all logics and replace all return views with json response.
If you looking for a basic login and create a basic API you can use Laravel Built-In Token Auth (No Package Required)
-
@ciaompe great answer, and also your API routes must return JSON response.
-
I added that bro.. Thnx
-
@ciaompe my pleasure bro...