Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create Restful api for mobile app in laravel 5.2

I'm creating an api for a mobile app in laravel version 5.2, but I don't have any idea how to return exception in JSON format. I've been doing api development and tested using chrome postman.

Please help me how can I start with laravel 5.2?

I can't understand how to set error response in laravel 5.2. I've already tried below plugin, but still didn't succeed:

  1. json-api with laravel,
  2. dingo/api, it's work with laravel 4

How can we do authentication in laravel 5.2 from mobile app?

Something good references and video link so I can learn and development in laravel 5.2 very friendly.

like image 481
Dhaval Varsada Avatar asked Jan 07 '16 06:01

Dhaval Varsada


People also ask

Is Laravel API RESTful?

Laravel provides a convenient way to create Restful APIs via resourceful controllers. Create a route for the resourceful controller in routes/api.

How use Laravel application as both web application and REST API?

it's simple! just make your API's and then call them with both Vue (for web) and flutter(for mobile). you dont need to specify them for seprate usage!

Can I use Laravel for mobile app?

Firstly, you'll need to build an API from your Laravel app to use it as a 'back end'. You won't be able to use your existing codebase to create the front end of your mobile apps, so you will have to rebuild the features and functionalities of your existing web app for the iOS and Android platforms.


2 Answers

For the creation of Restful API using Laravel 5.2 you could use below mention Laravel API generator Package .

https://github.com/InfyOmLabs/laravel-generator

As well as for the Authentication based on Token you could refer below mention Link.

https://gistlog.co/JacobBennett/090369fbab0b31130b51

One more additional thing if you have already created database / system and wants to use that for the creation of API using Laravel Generator package than use below mention command.

php artisan infyom:api_scaffold Packages --fromTable --tableName=packages

Hope this information will help you to create complete Restful API using Laravel 5.2

like image 145
Nayan Jogi Avatar answered Nov 08 '22 12:11

Nayan Jogi


I am also creating a Web Based Application for Android using Laravel 5.2 and we are using Rest API for this process. We are using API Guard for the purpose of Authentication. It works Perfect for us. We are authenticating it for Android as well as AngularJS and works fine for us. https://github.com/chrisbjr/api-guard. A Clear Documentation is Provided here. Hope so you have got your doubt cleared using this.

like image 2
Naresh Kumar P Avatar answered Nov 08 '22 13:11

Naresh Kumar P