Upload
andrew-del-prete
View
597
Download
2
Embed Size (px)
DESCRIPTION
This is the presentation I put together for the LaravelDFW September Meetup. I followed the slides with a live demonstration on how to use Laravel + Restangular. The whole presentation can be seen here. http://www.laraveldfw.com/live
Citation preview
Laravel + RestangularLet’s do this.
But first
Andrew Del Prete@pathsofdesign
www.pathsofdesign.com
Who am I?
What we’re covering
• Some of the benefits of Restangular over alternatives
• An intro on how to do basic HTTP requests with Restangular
• A quick review of Laravel Resource Routes
• Build a small SPA (Korra) to demonstrate how it works
• Online resources
• That’s all folks
• Questions
So what is Restangular?
“Restangular is an AngularJS service that simplifies common GET, POST, DELETE, and UPDATE requests with a minimum of client code. It's a perfect fit for any WebApp that consumes data from a RESTful API.”
https://github.com/mgonto/restangular
Benefits Much?• Creating a Single Page Application (SPA) is easier than ever.
• Promises Promises.
• A great way to simplify JSON CRUD.
• Utilizes explicit Syntax that is easy to remember.
• Allows you to forget full URLs.
• Supports all HTTP methods.
• Helps the developer throw away the jQuery “Crutch”
• Allows you to chain methods together for complex requests.
• Very configurable / customizable.
And more!
Can’t I already AJAX?
jQuery offers a great line of AJAXY methods. $.ajax, $.get, $.json, etc… The problem is
these methods are low level and are not abstracted into a reusable service.
$http is the low level AJAX service that’s native to AngularJS. It’s a lot like jQuery’s
AJAX methods but can be injected into Angular and is what Restangular builds upon
internally.
$resource is the native REST Module in AngularJS. It’s difficult to use and buggy.
Restangular aims to solve the flaws of $resource and provide a better service for REST.
The alternatives
Restangular Requirements
AngularJS
Lodash or Underscore
Setting up Restangular
Creating Main Restangular ObjectThere are 3 ways of creating a main Restangular object. The first one and most
common is by stating the main route of all requests. The second one is by stating the
main route and object of all requests. Each object can be built upon and utilized later
in our code to do various requests.
Get, Post, Put, and Delete
Chaining Requests
Let’s Build Something!
ResourcesKorra - https://github.com/Pathsofdesign/korra The blog experiment I demonstrated. I hope to add features and refine.
Restangular Docs - https://github.com/mgonto/restangularSurprisingly good Documentation!
ng-newsletter - http://www.ng-newsletter.com/posts/restangular.htmlGreat resource for AngularJS all around.
That’s all Folks!