symfony & javascript. combining the best of two worlds
DESCRIPTION
TRANSCRIPT
![Page 1: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/1.jpg)
Symfony & JavaScript
Combining the best of two worlds
Nacho Martín@nacmartin
![Page 2: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/2.jpg)
Symfony & JavaScript
Combining the best of two worlds
Nacho Martín@nacmartin
![Page 3: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/3.jpg)
A bit of history
![Page 4: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/4.jpg)
Client
Server
![Page 5: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/5.jpg)
Client
Server
![Page 6: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/6.jpg)
Client
Server
![Page 7: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/7.jpg)
What’s that??
![Page 8: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/8.jpg)
What’s that??
It’s just a JavaScript
![Page 9: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/9.jpg)
Client
Server
![Page 10: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/10.jpg)
Client
Server
![Page 11: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/11.jpg)
Client
Server
![Page 12: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/12.jpg)
Client
Server
![Page 13: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/13.jpg)
Client
Server
![Page 14: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/14.jpg)
Why should I care?
![Page 15: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/15.jpg)
Users like it
![Page 16: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/16.jpg)
Users like it
You want to do it
![Page 17: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/17.jpg)
Users it
You want to do it
expect
![Page 18: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/18.jpg)
Users it
You to do itneed
expect
![Page 19: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/19.jpg)
It’s still just a JavaScript
![Page 20: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/20.jpg)
But, but...
JavaScript is HARD
![Page 21: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/21.jpg)
Sequential
![Page 22: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/22.jpg)
Sequential
![Page 23: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/23.jpg)
Sequential
![Page 24: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/24.jpg)
Sequential
![Page 25: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/25.jpg)
Sequential
![Page 26: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/26.jpg)
Sequential
![Page 27: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/27.jpg)
Sequential
![Page 28: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/28.jpg)
Asynchronous
![Page 29: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/29.jpg)
Asynchronous
![Page 30: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/30.jpg)
Asynchronous
![Page 31: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/31.jpg)
AsynchronousCall me back
![Page 32: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/32.jpg)
Asynchronous
![Page 33: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/33.jpg)
Asynchronous
![Page 34: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/34.jpg)
Asynchronous
Done !
![Page 35: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/35.jpg)
Asynchronous
![Page 36: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/36.jpg)
for(var i = 1; i <= 5; i++) { console.log(i);}
![Page 37: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/37.jpg)
for(var i = 1; i <= 5; i++) { console.log(i);}
12345
![Page 38: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/38.jpg)
for(var i = 1; i <= 5; i++) { setTimeout(function() { console.log(i); }, 100);}
![Page 39: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/39.jpg)
for(var i = 1; i <= 5; i++) { setTimeout(function() { console.log(i); }, 100);}
66666
![Page 40: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/40.jpg)
for(var i = 1; i <= 5; i++) { (function() { var j = i; setTimeout( function() { console.log(j); }, 100); })();}
![Page 41: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/41.jpg)
for(var i = 1; i <= 5; i++) { (function() { var j = i; setTimeout( function() { console.log(j); }, 100); })();}
12345
![Page 42: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/42.jpg)
Callback nesting
![Page 43: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/43.jpg)
Callback nesting
• Events
![Page 44: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/44.jpg)
Callback nesting
• Events• Async.js
![Page 45: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/45.jpg)
“this” gotchavar o = {};o.prop = {};
var o.f1 = function(){ var that = this;
this.prop.active = false;
var activate = function(){ that.prop.active = true;
};
activate();
};
![Page 46: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/46.jpg)
“this” gotchavar o = {};o.prop = {};
var o.f1 = function(){ var that = this;
this.prop.active = false;
var activate = function(){ that.prop.active = true;
};
activate();
};
![Page 47: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/47.jpg)
http://www.flickr.com/photos/bensonkua/3161323177/in/photostream/
![Page 48: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/48.jpg)
Douglas Crockford
![Page 49: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/49.jpg)
![Page 50: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/50.jpg)
But, but...
![Page 51: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/51.jpg)
But, but...
•Can be ugly
![Page 52: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/52.jpg)
But, but...
•Can be ugly
•Tons of crappy code
![Page 53: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/53.jpg)
But, but...
•Can be ugly
•Tons of crappy code
•Inconsistencies
![Page 54: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/54.jpg)
But, but...
•Can be ugly
•Tons of crappy code
•Inconsistencies
•Weird stuff inside
![Page 55: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/55.jpg)
But, but...
•Can be ugly
•Tons of crappy code
•Inconsistencies
•Weird stuff inside
•Huge community
![Page 56: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/56.jpg)
But, but...
•Can be ugly
•Tons of crappy code
•Inconsistencies
•Weird stuff inside
•Huge community
•Easy to get help
![Page 57: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/57.jpg)
But, but...
•Can be ugly
•Tons of crappy code
•Inconsistencies
•Weird stuff inside
•Huge community
•Easy to get help
•Low entry barrier
![Page 58: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/58.jpg)
But, but...
•Can be ugly
•Tons of crappy code
•Inconsistencies
•Weird stuff inside
•Huge community
•Easy to get help
•Low entry barrier
•Is everywhere
![Page 59: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/59.jpg)
http://www.flickr.com/photos/73935252@N00/181308667
![Page 60: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/60.jpg)
http://www.flickr.com/photos/73935252@N00/181308667http://www.flickr.com/photos/39865537@N03/4395203300
The team needs discipline
compromise readablity
![Page 61: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/61.jpg)
http://www.flickr.com/photos/43322231@N07/5589147122
Pick your battles
![Page 62: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/62.jpg)
is the perfect complement
![Page 63: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/63.jpg)
is the perfect complement
![Page 64: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/64.jpg)
Client side JS
![Page 65: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/65.jpg)
Text
Level I
http://www.flickr.com/photos/lecates/307250887/
![Page 66: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/66.jpg)
Assetic
![Page 67: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/67.jpg)
FOSJsRouterBundle
/** * @Route ("/foo/{id}/bar", name="my_route_to_expose", options={"expose"=true}) */public function exposedAction($foo)
Routing.generate('my_route_to_expose', { id: 10 });// /foo/10/bar
PHP
JS
![Page 68: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/68.jpg)
Text
Level II
http://www.flickr.com/photos/49766155@N07/4945673508
![Page 69: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/69.jpg)
Client
Server
![Page 70: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/70.jpg)
Client
Server
![Page 71: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/71.jpg)
Client
Server
![Page 72: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/72.jpg)
Then Symfony...?
![Page 73: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/73.jpg)
Then Symfony...?
Still does almost everything
![Page 74: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/74.jpg)
•Small library
•Stable for JS world
•Active
•Open Source
•Popular
![Page 75: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/75.jpg)
•Models
•Collections
•Views
•Templates
•Routing
•Models
•Repositories
•Controllers
•Views
•Routing
![Page 76: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/76.jpg)
ModelModel
View
![Page 77: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/77.jpg)
ModelModel
View
Books.fetch()
Books=new Backbone.collection();
Books.url = ‘/books’;
![Page 78: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/78.jpg)
ModelModel
View
GET /books
Books.fetch()
Books=new Backbone.collection();
Books.url = ‘/books’;
![Page 79: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/79.jpg)
ModelModel
View
GET /books
Books.fetch()
Books=new Backbone.collection();
Books.url = ‘/books’;
![Page 80: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/80.jpg)
ModelModel
View
GET /books
Books.fetch()
Books=new Backbone.collection();
Books.url = ‘/books’;
Books.on(‘reset’, this.render);
![Page 81: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/81.jpg)
ModelModel
View
GET /books
Books.fetch()
Books=new Backbone.collection();
Books.url = ‘/books’;
Books.on(‘reset’, this.render);
![Page 82: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/82.jpg)
ModelModel
View
GET /books
Books.fetch()
Books=new Backbone.collection();
Books.url = ‘/books’;
Books.on(‘reset’, this.render);
![Page 83: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/83.jpg)
ModelModel
View
![Page 84: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/84.jpg)
ModelModel
Viewevents: { ‘click .mybutton’: ‘doStuffAndSave’}
![Page 85: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/85.jpg)
ModelModel
Viewevents: { ‘click .mybutton’: ‘doStuffAndSave’}
![Page 86: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/86.jpg)
ModelModel
Viewevents: { ‘click .mybutton’: ‘doStuffAndSave’}
doStuffAndSave: function() { var book = Books.get(3); book.stuff(); Books.get(3).save();}
![Page 87: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/87.jpg)
ModelModel
Viewevents: { ‘click .mybutton’: ‘doStuffAndSave’}
doStuffAndSave: function() { var book = Books.get(3); book.stuff(); Books.get(3).save();}
![Page 88: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/88.jpg)
ModelModel
View
PUT /books/3
events: { ‘click .mybutton’: ‘doStuffAndSave’}
doStuffAndSave: function() { var book = Books.get(3); book.stuff(); Books.get(3).save();}
![Page 89: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/89.jpg)
http://www.flickr.com/photos/kaptainkobold/3203311346/
Build an API
![Page 90: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/90.jpg)
FOSRestBundle
/** * @View() * GET /users */ public function getUsersAction() { return $this->getDoctrine()->getRepository('myBundle:User')->findAll(); }
![Page 91: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/91.jpg)
Response[ {“id”:1, “name”:”nacho”, “password”: “X$$%$X”, “email”:”[email protected]”, “profile”: { “id”:3, “phone”: “666666666”} } }, {...},]
![Page 92: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/92.jpg)
JMSSerializerMyBundle\User: exclusion_policy: ALL properties: id: expose: true name: expose: true email: expose: true
![Page 93: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/93.jpg)
MyBundle\User: exclusion_policy: ALL properties: id: expose: true name: expose: true email: expose: true callback_methods: pre_serialize: serializeProfile
JMSSerializer
![Page 94: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/94.jpg)
JMSSerializer
public function serializeProfile(){ $this->phone = $this->profile->getPhone(); $this->profile = null;}
![Page 96: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/96.jpg)
Deserialize forms
•SimpleThingsFormSerializeBundle
•Symfony-cmf/CreateBundle
•http://williamdurand.fr/2012/08/02/rest-apis-with-symfony2-the-right-way/
![Page 97: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/97.jpg)
NelmioApiDocBundle
![Page 98: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/98.jpg)
Twig.js
Twig
![Page 99: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/99.jpg)
Twig.js
TwigBackbone
![Page 100: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/100.jpg)
Twig.js
{% javascripts "@MyBundle/Resources/views/tmpl.html.twig" filter="twig_js, ?yui_js" %} <script language="javascript" src="{{ asset_url }}"> </script>{% endjavascripts %}
![Page 101: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/101.jpg)
Server side JS
![Page 102: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/102.jpg)
Client
Server
![Page 103: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/103.jpg)
Client
Server
![Page 104: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/104.jpg)
Client
Server
![Page 105: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/105.jpg)
Client
Server
![Page 106: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/106.jpg)
![Page 107: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/107.jpg)
What for
![Page 108: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/108.jpg)
•Streaming data
What for
![Page 109: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/109.jpg)
•Streaming data
•Soft realtime
•Chats
•Notifications
What for
![Page 110: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/110.jpg)
Challenges to face
![Page 111: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/111.jpg)
•Organization of a big code base
Challenges to face
![Page 112: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/112.jpg)
•Organization of a big code base
•General lower level of abstraction
Challenges to face
![Page 113: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/113.jpg)
•Organization of a big code base
•General lower level of abstraction
•Deployment
•Serving static files
Challenges to face
![Page 114: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/114.jpg)
•Organization of a big code base
•General lower level of abstraction
•Deployment
•Serving static files
Challenges to face
![Page 115: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/115.jpg)
Use case:Notifications
![Page 116: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/116.jpg)
![Page 117: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/117.jpg)
![Page 118: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/118.jpg)
♥
![Page 119: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/119.jpg)
♥
![Page 120: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/120.jpg)
♥
![Page 121: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/121.jpg)
♥
![Page 122: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/122.jpg)
Websockets
io.sockets.on('connection', function (socket) { socket.join('user1'); socket.broadcast.to('user1').emit('Hi user 1');});
![Page 123: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/123.jpg)
http://www.flickr.com/photos/45940879@N04/6277724736
Dealing with secrets
![Page 124: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/124.jpg)
![Page 125: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/125.jpg)
http
MQ
![Page 126: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/126.jpg)
The pusher way
secret secret
![Page 127: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/127.jpg)
The pusher way
socket id
secret secret
![Page 128: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/128.jpg)
The pusher way
socket id
chan
nel n
ame &
sock
et id
secret secret
![Page 129: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/129.jpg)
The pusher way
socket id
chan
nel n
ame &
sock
et id
key:s
ignatu
re
secret secret
![Page 130: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/130.jpg)
The pusher way
socket id
chan
nel n
ame &
sock
et id
key:s
ignatu
rechannel name &
key:signature
secret secret
![Page 131: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/131.jpg)
Deploy
![Page 132: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/132.jpg)
Deploy
![Page 133: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/133.jpg)
Deploy
![Page 134: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/134.jpg)
![Page 135: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/135.jpg)
It’s just a JavaScript
![Page 136: Symfony & Javascript. Combining the best of two worlds](https://reader034.vdocuments.mx/reader034/viewer/2022051819/54c69aa54a795911528b4580/html5/thumbnails/136.jpg)
Thanks
http://www.flickr.com/photos/95572727@N00/2380543038
Nacho Martín@nacmartin