Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop

    Laravel API help

    Back-End Development
    laravel backend api restful api
    3
    5
    1100
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Pasindu Mihirantha
      Pasindu Mihirantha last edited by

      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

      1 Reply Last reply Reply Quote 3
      • ciaompe
        ciaompe last edited by ciaompe

        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


        1. Login
        2. Register
        3. Other Routes on your application

        ex : post/topic, get/topic, edit/topic

        Source

        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)

        Check This Out

        1 Reply Last reply Reply Quote 2
        • dev_lak
          dev_lak last edited by

          @ciaompe great answer, and also your API routes must return JSON response.

          ciaompe 1 Reply Last reply Reply Quote 0
          • ciaompe
            ciaompe @dev_lak last edited by

            @dev_lak

            I added that bro.. Thnx

            dev_lak 1 Reply Last reply Reply Quote 0
            • dev_lak
              dev_lak @ciaompe last edited by

              @ciaompe my pleasure bro...

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              4
              Online

              3.6k
              Users

              1.3k
              Topics

              5.3k
              Posts

              • Privacy
              • Terms & Conditions
              • Donate

              © Copyrights and All right reserved Lanka Developers Community

              Powered by Axis Technologies (PVT) Ltd

              Made with in Sri Lanka

              | |