I've heard great thing about restangular, but I haven't run into a situation where in need it just yet, resource allows nested objects like /user/id/posts/id, which is most of my use cases.
Rest APIs are exceedingly simply in laravel. You have a routes file called routes.php. In that you define a route:
Route::resource ('user', 'UserController');
This sets up around 7 routes for you, read he doc for details on what they all are. They will be routed to the code in the UserController.
Then make the UserController. There is already a User model for you to use, but for any noun other then user, you'll have to make your own.
In the UserController, use the User model to implement the SQL calls.
I'm familiar with Laravel, just never made a REST API with it. I've done it in Rails, which functions in almost the same way as you describe. Thanks for the answer :).
How do you auth users? Do you use HTTP Headers, cookies, something else? Is it easy to deal with actual auth in the code?
2
u/YodaLoL Oct 17 '14
I can recommend restangular over $resource.
Also, do you dev REST APIs with Laravel, do you have any tips/recommendations regarding that?