0

Our company is about to start a real estate project and have decided to go with the laravel 5.3 framework. The first phase is to write the apis and then these apis will be consumed by the mobile team and the frontend team to build the official mobile app and the web portal respectively.

Now I am confused whether to use laravel's built-in Resource controllers (as instructed in this tutorial http://www.programmableweb.com/news/how-to-build-restful-apis-using-php-and-laravel/how-to/2014/08/13) or use the Dingo Api framework.

Could you please help me which one should I go for and why as per the requirements i mentioned above?

Thanks in advance

Phantom007
  • 2,079
  • 4
  • 25
  • 37

1 Answers1

1

Since, Laravel 5.3 comes with Passport (for api authentication), I would suggest you to use Resource controller, which is very simple and easy to work with, and also it create a meaningful end points

Route::resource('post','PostController');

GET /post/{post}
POST /post
EDIT /post/{post}/edit
DELETE /post/{post}
Jagadesha NH
  • 2,529
  • 2
  • 23
  • 41
  • Thanks for your reply. If I want JWT based authentication can I do it with laravel 5.3 alone? – Phantom007 Dec 27 '16 at 07:54
  • Passport comes with oauth2.0 and which supports jwt also. – Jagadesha NH Dec 27 '16 at 08:04
  • Is there any specific link where i can learn how to implement jwt using passport? – Phantom007 Dec 27 '16 at 08:08
  • https://jagadeshanh.wordpress.com/2016/12/27/using-laravel-passport-for-api-authentication/ hope this helps you – Jagadesha NH Dec 27 '16 at 09:17
  • Great! Thanks for writing an article on it. Few questions however (1) To get the JWT, you made a POST request with client_id and client_secret. So how will my customers know this id and secret? Will these be fixed for ALL my customers? (2) If I want to have diff client_id and client_secret for each customer, do I have to manually run php artisan passport:install everytime? Thanks – Phantom007 Dec 27 '16 at 11:18
  • It completely depends on you, If you want to implement something like facebook apps, then each user who creates an app will get client_id, or you just have one android app, and one web app, then just create two clients one for android and one for web and use these credentials. check this link for more information https://laravel.com/docs/5.3/passport – Jagadesha NH Dec 27 '16 at 11:50
  • I just want my users to be able to get a json token when they pass their username and password and nothing else. Is that possible? – Phantom007 Dec 27 '16 at 11:58
  • Yes it is possible. Check Requesting tokens in that passport documentation. There is an example also. – Jagadesha NH Dec 27 '16 at 12:00
  • All the examples require you to specify the client_id :( – Phantom007 Dec 27 '16 at 12:08
  • @Phantom007 yes bro, with one client_id, you can have many Bearer tokens, I will post an example wait. – Jagadesha NH Dec 27 '16 at 12:16
  • But its not the right way, I cannot tell all my third party api users to use the same client id. – Phantom007 Dec 27 '16 at 12:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/131616/discussion-between-jagadesha-nh-and-phantom007). – Jagadesha NH Dec 27 '16 at 18:04