how to make rest api in laravel

In this world of coding, the data is the most important part and more important than the transfer of data and its extracting useful information from it. APIs are built so that your backend logic can be easily integrated with any system and can be given to anyone without giving business logic. There different platforms like website, different mobile platforms but basically all are doing the same thing but in different logic. So lets take an example if you have list of candidates in your database and different platforms have to show these data's, so you would give a url and some credentials and ask them to request to this url and you will get data. So this is basic introduction to API.

So now API are also built in many languages. Here we will take talk about APIs in php language and with help of php framework Laravel. You can go through the detail of introduction of laravel in our previous post
https://unboxknowledge.blogspot.com/2017/11/which-framework-is-the-best-for-php.html

and its installation
https://unboxknowledge.blogspot.com/2017/11/how-to-install-laravel-in-ubuntu.html

After successful installation, you have to make one controller, one model and declaration of model in the controller and mentioning the controller method in routes.php

The first step would be deciding your input parameters or the request parameters and method type (post or get .etc) Mention method type in routes.php. Then in controller use input validators to make necessary parameters or else written with a message. Also use middlewares for authentication purpose. Once request passes through input validators. Then comes your logic , where you can interact with models and fetch data from it and perform necessary actions and pass it in response as required by client.

The database credentials can be stored in .env file and can be fetched in config/database.php

Now use postman to test your API. Enter your URL and select the type of your method and add necessary authentication parameters in header and request parameters in your body part. So your basic API is ready.



Hope you understand the basic of APIs and please share such kind of knowledge and let us know if you want to write in our blog.

Few points about our Unbox Knowledge.We at Unbox Knowledge make account advertisement analysis and go through apps available at each store or knowledge bank with best interface and userfriendly. We don't black marketing where things are written wrong and spread viral all around the world. We are into making world a better place. Example can be given of booking budget and in whichever field we are, we will have great knowledge of all things.. We also available on pinterest, so play plus post or rather posts in each pradesh of India. Now in december, we posted many useful resources from east to west and north to south. You can connect with email facebook or whatever the online platform we have. We also give mobile launched or before it launches like redmi 5a. So share our link and make market a medium of message. We will provide info on latest mobile. you can know us with info of latest mobile.We are like wikipedia for short description, we can be searched as redbus wikipedia. So you can join knowledge sharing revolution with us. make everyone read this. We gave all operators detail too like mtnl mumbai or whatever need.  Example can be given of booking budget and in whichever field we are, we will have great knowledge of all things. latest mobile info are always available with us. you can write if you buy latest mobile or any of your friend buys latest mobile. We will let know user about the cashback or any ofer going on in the market. We will let you know user how to claim the profit. When true color comes in front of all of us. You can give comment or rather comments to improve us and yourself also. So facts feature or rather features about any framework, you know or your friends, let user world also know. You play game at google like great india or indian so we posted on game in january.  We also given blog on games like counter stike which will create a world of game lovers and currently custom daily games are available that can be played again and again. A stripe of post of talking about tata technology, time twitter, and our unique word unbox for user and a variant version. Please visit official website of vivo in west world and xiaomi. We will give the specification of mobiles like built camera etc of any mobiles and other features too. . So you can join knowledge sharing revolution with us. make everyone read this. You will get ideas about recharge or bus booking operator like redbus or india's No. 1 brand redmi or shut down of reliance.  So keep share and soon source will start knowing you and you step ahead each day. We gave all operators detail too like mtnl mumbai or whatever need. And please play militia mini on your mobile. You will get ideas about recharge or bus booking operator like redbus or india's No. 1 brand redmi or shut down of reliance.  So keep share and soon source will start knowing you and you step ahead each day. We will be ready to write on latest mobile. Please let us know your latest mobile and if we write your on latest mobile and by getting your latest mobile data from other resources, asking friends and a whole new post would be written on latest mobile. We are like wikipedia for short description, we can be searched as redbus wikipedia. redbus wikipedia can be other name of this post. Data will be saved on google blogger server. We are like prepaid and price of knowledge will be free. Rather we want to create a profile and You can get knowledge by writing on google redbus wikipedia or something related to redbus wikipedia. In november we gave post about offers, online operators and then mobile brands like oppo or regarding page of payments through phone using phonepe and phones are very much useful Technology parts comes with laravel a framework of php, we gave on that also.

Comments

Simple Debt Manager & Tracker app

Get it on Google Play