SlideShare a Scribd company logo
symfony & jQuery ties and separations Massimiliano Arione May, 14th 2011
About me 2001 PHP 2004 PEAR 2007 symfony 2009 agile
symfony
jQuery
MVC
CPB
B ehavior progressive enhancement AJAX
PROGRESSIVE ENHANCEMENT: THE WRONG WAY sfFormExtraPlugin : sfWidgetFormJQueryDate sfWidgetFormJQueryAutocompleter sfWidgetFormTextareaTinyMCE
PROGRESSIVE   ENHACEMENT: THE GOOD WAY Just use  plain  Javascript!
AJAX: THE 4 STEPS Javascript catches an interaction with user, or with other browser events  an XMLHttpRequest object send a request to server, without breaking the flow an XML (or other format) is returned by server  Javascript decodes data from file and interacts with page
AJAX: THE 4 STEPS Javascript catches an interaction with user, or with other browser events  an XMLHttpRequest object send a request to server, without breaking the flow an XML (or other format) is returned by server  Javascript decodes data from file and interacts with page
AJAX: THE 4 STEPS Javascript catches an interaction with user, or with other browser events  an XMLHttpRequest object send a request to server, without breaking the flow an XML (or other format) is returned by server  Javascript decodes data from file and interacts with page
AJAX: THE 4 STEPS Javascript catches an interaction with user, or with other browser events  an XMLHttpRequest object send a request to server, without breaking the flow an XML (or other format) is returned by server  Javascript decodes data from file and interacts with page
AJAX: THE WRONG WAY sf 1.0: Javascript helper  sf 1.4: sfJqueryPlugin <?php echo   link_to_remote ('...'); echo   jq_link_to_remote ('...');
AJAX: THE GOOD WAY code as if Javascript wouldn't exist write your jQuery functions in the big  $().ready()  function do little adaptions to your controller write another view (tipically a JSON one)
AJAX: THE GOOD WAY code as if Javascript wouldn't exist write your jQuery functions in the big  $().ready()  function do little adaptions to your controller write another view (tipically a JSON one)
AJAX: THE GOOD WAY code as if Javascript wouldn't exist write your jQuery functions in the big  $().ready()  function do little adaptions to your controller write another view (tipically a JSON one)
AJAX: THE GOOD WAY code as if Javascript wouldn't exist write your jQuery functions in the big  $().ready()  function do little adaptions to your controller write another view (tipically a JSON one)
IN PRACTICE: LINK <?php // in the view   echo   link_to (' + ', ' cart_increase ', $item) $(' div#cart a.increase ').click(ajaxIncrease);
var  ajaxIncrease =  function (e) {   $.ajax({     url:     this.href + ' ?sf_format=json ',     success:  function (r) { increase(r, e.target); }   });    return false ; }; var  increase =  function (result, a) {    var  $span = $(a).parents(' li ').find(' span.qty ');    var  newqty = parseInt($span.text(),  10 ) +  1 ;   $span.empty().append(newqty);   $(' span#total ').empty();   $(' span#total ').append(result.total); };
<?php // in the view   // cartIncreaseSuccess.json.php use_helper(' Number ');   $arr = array(   ' total ' => format_currency($sf_user->getCartTotal(), ' EUR '), ); echo  json_encode($arr);
<?php // in the controller   // actions.class.php public  function  executeCartIncrease(sfWebRequest $request) {   $this->product = $this->getRoute()->getProduct();   $this->getUser()->cartIncrease($this->product);   // was $this->redirect('@homepage');       $this->redirectUnless($request->isXmlHttpRequest(), ' @homepage '); }
IN PRACTICE: FORM $(' div#filters form ').submit(ajaxFilter);
var  ajaxFilter = function(e) {    var  $form = $(this);   $.ajax({     type: ' POST ',     url:  $form.attr(' action ') + ' ?sf_format=json ',     data: $form.serializeArray(),     success: showProducts   });    return false ; };
Thanks! Massimiliano Arione @ garakkio blog.garak.it github.com/garak/sfjqec joind.in/talk/view/3034

More Related Content

What's hot (20)

Introduction to thymeleaf
Introduction to thymeleafIntroduction to thymeleaf
Introduction to thymeleaf
NexThoughts Technologies
 
Laravel the right way
Laravel   the right wayLaravel   the right way
Laravel the right way
Matheus Marabesi
 
Excellent
ExcellentExcellent
Excellent
Marco Otte-Witte
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To Lamp
Amzad Hossain
 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
Marco Otte-Witte
 
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016
Matheus Marabesi
 
Broadleaf Presents Thymeleaf
Broadleaf Presents ThymeleafBroadleaf Presents Thymeleaf
Broadleaf Presents Thymeleaf
Broadleaf Commerce
 
Introduction to JQuery
Introduction to JQueryIntroduction to JQuery
Introduction to JQuery
MobME Technical
 
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
Matheus Marabesi
 
Thymeleaf Introduction
Thymeleaf IntroductionThymeleaf Introduction
Thymeleaf Introduction
Anthony Chen
 
ZCPE - PHP Conference 2015
ZCPE   - PHP Conference 2015ZCPE   - PHP Conference 2015
ZCPE - PHP Conference 2015
Matheus Marabesi
 
シックス・アパート・フレームワーク
シックス・アパート・フレームワークシックス・アパート・フレームワーク
シックス・アパート・フレームワーク
Takatsugu Shigeta
 
Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5
Oleg Poludnenko
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
Caldera Labs
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
Tudor Constantin
 
Changing Template Engine
Changing Template EngineChanging Template Engine
Changing Template Engine
Takatsugu Shigeta
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
Yusuke Wada
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With Blogging
Takatsugu Shigeta
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
Matt Todd
 
Merb jQuery
Merb jQueryMerb jQuery
Merb jQuery
Yehuda Katz
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To Lamp
Amzad Hossain
 
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016
Matheus Marabesi
 
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
TDC 2016 (Florianópolis) - Vá para o próximo nível - Dicas e truques para a c...
Matheus Marabesi
 
Thymeleaf Introduction
Thymeleaf IntroductionThymeleaf Introduction
Thymeleaf Introduction
Anthony Chen
 
ZCPE - PHP Conference 2015
ZCPE   - PHP Conference 2015ZCPE   - PHP Conference 2015
ZCPE - PHP Conference 2015
Matheus Marabesi
 
シックス・アパート・フレームワーク
シックス・アパート・フレームワークシックス・アパート・フレームワーク
シックス・アパート・フレームワーク
Takatsugu Shigeta
 
Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5
Oleg Poludnenko
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
Caldera Labs
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
Yusuke Wada
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With Blogging
Takatsugu Shigeta
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
Matt Todd
 

Viewers also liked (6)

Priority based K-Erlang Distribution Method in Cloud Computing
Priority based K-Erlang Distribution Method in Cloud ComputingPriority based K-Erlang Distribution Method in Cloud Computing
Priority based K-Erlang Distribution Method in Cloud Computing
idescitation
 
Frontend caching - PHP Day, Italy, 2011
Frontend caching - PHP Day, Italy, 2011Frontend caching - PHP Day, Italy, 2011
Frontend caching - PHP Day, Italy, 2011
Helgi Þormar Þorbjörnsson
 
PHP Day 2011 PHP goes to the cloud
PHP Day 2011 PHP goes to the cloudPHP Day 2011 PHP goes to the cloud
PHP Day 2011 PHP goes to the cloud
pietrobr
 
Integrating Erlang with PHP
Integrating Erlang with PHPIntegrating Erlang with PHP
Integrating Erlang with PHP
Alvaro Videla
 
Localisation typo3
Localisation typo3Localisation typo3
Localisation typo3
Daniel
 
An year of Pomodoros
An year of PomodorosAn year of Pomodoros
An year of Pomodoros
Giorgio Sironi
 
Priority based K-Erlang Distribution Method in Cloud Computing
Priority based K-Erlang Distribution Method in Cloud ComputingPriority based K-Erlang Distribution Method in Cloud Computing
Priority based K-Erlang Distribution Method in Cloud Computing
idescitation
 
PHP Day 2011 PHP goes to the cloud
PHP Day 2011 PHP goes to the cloudPHP Day 2011 PHP goes to the cloud
PHP Day 2011 PHP goes to the cloud
pietrobr
 
Integrating Erlang with PHP
Integrating Erlang with PHPIntegrating Erlang with PHP
Integrating Erlang with PHP
Alvaro Videla
 
Localisation typo3
Localisation typo3Localisation typo3
Localisation typo3
Daniel
 
Ad

Similar to symfony & jQuery (phpDay) (20)

Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j query
Tricode (part of Dept)
 
Eugene Andruszczenko: jQuery
Eugene Andruszczenko: jQueryEugene Andruszczenko: jQuery
Eugene Andruszczenko: jQuery
Refresh Events
 
jQuery Presentation - Refresh Events
jQuery Presentation - Refresh EventsjQuery Presentation - Refresh Events
jQuery Presentation - Refresh Events
Eugene Andruszczenko
 
jQuery, CSS3 and ColdFusion
jQuery, CSS3 and ColdFusionjQuery, CSS3 and ColdFusion
jQuery, CSS3 and ColdFusion
Denard Springle IV
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with Ajax
Wildan Maulana
 
ajax_pdf
ajax_pdfajax_pdf
ajax_pdf
tutorialsruby
 
ajax_pdf
ajax_pdfajax_pdf
ajax_pdf
tutorialsruby
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
Alive Kuo
 
Ajax
AjaxAjax
Ajax
Rathan Raj
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
Ajax
AjaxAjax
Ajax
jainaman
 
Ajax3
Ajax3Ajax3
Ajax3
Brian Moschel
 
jQuery and AJAX with Rails
jQuery and AJAX with RailsjQuery and AJAX with Rails
jQuery and AJAX with Rails
Alan Hecht
 
JavaScript JQUERY AJAX
JavaScript JQUERY AJAXJavaScript JQUERY AJAX
JavaScript JQUERY AJAX
Makarand Bhatambarekar
 
Ajax
AjaxAjax
Ajax
TSUBHASHRI
 
jQuery Presentation to Rails Developers
jQuery Presentation to Rails DevelopersjQuery Presentation to Rails Developers
jQuery Presentation to Rails Developers
Yehuda Katz
 
Orbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyOrbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case Study
Mark Meeker
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
baygross
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks Trivia
Cognizant
 
Ajax
AjaxAjax
Ajax
Nibin Manuel
 
Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j query
Tricode (part of Dept)
 
Eugene Andruszczenko: jQuery
Eugene Andruszczenko: jQueryEugene Andruszczenko: jQuery
Eugene Andruszczenko: jQuery
Refresh Events
 
jQuery Presentation - Refresh Events
jQuery Presentation - Refresh EventsjQuery Presentation - Refresh Events
jQuery Presentation - Refresh Events
Eugene Andruszczenko
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with Ajax
Wildan Maulana
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
Alive Kuo
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
jQuery and AJAX with Rails
jQuery and AJAX with RailsjQuery and AJAX with Rails
jQuery and AJAX with Rails
Alan Hecht
 
jQuery Presentation to Rails Developers
jQuery Presentation to Rails DevelopersjQuery Presentation to Rails Developers
jQuery Presentation to Rails Developers
Yehuda Katz
 
Orbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case StudyOrbitz and Spring Webflow Case Study
Orbitz and Spring Webflow Case Study
Mark Meeker
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
baygross
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks Trivia
Cognizant
 
Ad

More from Massimiliano Arione (20)

Typed models pug roma febbraio 2020
Typed models   pug roma febbraio 2020Typed models   pug roma febbraio 2020
Typed models pug roma febbraio 2020
Massimiliano Arione
 
Pipelines!
Pipelines! Pipelines!
Pipelines!
Massimiliano Arione
 
Il nostro amico Stan
Il nostro amico Stan   Il nostro amico Stan
Il nostro amico Stan
Massimiliano Arione
 
PSR7 - interoperabilità HTTP
PSR7 - interoperabilità HTTPPSR7 - interoperabilità HTTP
PSR7 - interoperabilità HTTP
Massimiliano Arione
 
Disinstallare fos user bundle e vivere felici
Disinstallare fos user bundle e vivere feliciDisinstallare fos user bundle e vivere felici
Disinstallare fos user bundle e vivere felici
Massimiliano Arione
 
MAGA - PUG Roma giugno 2017
MAGA - PUG Roma giugno 2017MAGA - PUG Roma giugno 2017
MAGA - PUG Roma giugno 2017
Massimiliano Arione
 
PHP7 e Rich Domain Model
PHP7 e Rich Domain ModelPHP7 e Rich Domain Model
PHP7 e Rich Domain Model
Massimiliano Arione
 
PHP on the desktop
PHP on the desktopPHP on the desktop
PHP on the desktop
Massimiliano Arione
 
Scrivere e leggere log con elastic
Scrivere e leggere log con elasticScrivere e leggere log con elastic
Scrivere e leggere log con elastic
Massimiliano Arione
 
The metrics
The metricsThe metrics
The metrics
Massimiliano Arione
 
Managing frontend libs in your Symfony project
Managing frontend libs in your Symfony projectManaging frontend libs in your Symfony project
Managing frontend libs in your Symfony project
Massimiliano Arione
 
Translating symfony docs
Translating symfony docsTranslating symfony docs
Translating symfony docs
Massimiliano Arione
 
Managing frontend libs in your php project
Managing frontend libs in your php projectManaging frontend libs in your php project
Managing frontend libs in your php project
Massimiliano Arione
 
Gestire librerie di frontend in php
Gestire librerie di frontend in phpGestire librerie di frontend in php
Gestire librerie di frontend in php
Massimiliano Arione
 
PHP, non lo stesso vecchio linguaggio
PHP, non lo stesso vecchio linguaggioPHP, non lo stesso vecchio linguaggio
PHP, non lo stesso vecchio linguaggio
Massimiliano Arione
 
Gestione delle dipendenze con Composer
Gestione delle dipendenze con ComposerGestione delle dipendenze con Composer
Gestione delle dipendenze con Composer
Massimiliano Arione
 
Migrare da symfony 1 a Symfony2
 Migrare da symfony 1 a Symfony2  Migrare da symfony 1 a Symfony2
Migrare da symfony 1 a Symfony2
Massimiliano Arione
 
Case study OmniAuto.it
Case study OmniAuto.itCase study OmniAuto.it
Case study OmniAuto.it
Massimiliano Arione
 
Symfony: un framework per il web
Symfony: un framework per il webSymfony: un framework per il web
Symfony: un framework per il web
Massimiliano Arione
 
Paypal + symfony
Paypal + symfonyPaypal + symfony
Paypal + symfony
Massimiliano Arione
 
Typed models pug roma febbraio 2020
Typed models   pug roma febbraio 2020Typed models   pug roma febbraio 2020
Typed models pug roma febbraio 2020
Massimiliano Arione
 
Disinstallare fos user bundle e vivere felici
Disinstallare fos user bundle e vivere feliciDisinstallare fos user bundle e vivere felici
Disinstallare fos user bundle e vivere felici
Massimiliano Arione
 
Scrivere e leggere log con elastic
Scrivere e leggere log con elasticScrivere e leggere log con elastic
Scrivere e leggere log con elastic
Massimiliano Arione
 
Managing frontend libs in your Symfony project
Managing frontend libs in your Symfony projectManaging frontend libs in your Symfony project
Managing frontend libs in your Symfony project
Massimiliano Arione
 
Managing frontend libs in your php project
Managing frontend libs in your php projectManaging frontend libs in your php project
Managing frontend libs in your php project
Massimiliano Arione
 
Gestire librerie di frontend in php
Gestire librerie di frontend in phpGestire librerie di frontend in php
Gestire librerie di frontend in php
Massimiliano Arione
 
PHP, non lo stesso vecchio linguaggio
PHP, non lo stesso vecchio linguaggioPHP, non lo stesso vecchio linguaggio
PHP, non lo stesso vecchio linguaggio
Massimiliano Arione
 
Gestione delle dipendenze con Composer
Gestione delle dipendenze con ComposerGestione delle dipendenze con Composer
Gestione delle dipendenze con Composer
Massimiliano Arione
 
Symfony: un framework per il web
Symfony: un framework per il webSymfony: un framework per il web
Symfony: un framework per il web
Massimiliano Arione
 

Recently uploaded (20)

Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptxISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
AyilurRamnath1
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to KnowWhat is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
SMACT Works
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
Edge AI and Vision Alliance
 
Dancing with AI - A Developer's Journey.pptx
Dancing with AI - A Developer's Journey.pptxDancing with AI - A Developer's Journey.pptx
Dancing with AI - A Developer's Journey.pptx
Elliott Richmond
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptxISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
AyilurRamnath1
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to KnowWhat is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
What is Oracle EPM A Guide to Oracle EPM Cloud Everything You Need to Know
SMACT Works
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
Edge AI and Vision Alliance
 
Dancing with AI - A Developer's Journey.pptx
Dancing with AI - A Developer's Journey.pptxDancing with AI - A Developer's Journey.pptx
Dancing with AI - A Developer's Journey.pptx
Elliott Richmond
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 

symfony & jQuery (phpDay)

  • 1. symfony & jQuery ties and separations Massimiliano Arione May, 14th 2011
  • 2. About me 2001 PHP 2004 PEAR 2007 symfony 2009 agile
  • 5. MVC
  • 6. CPB
  • 7. B ehavior progressive enhancement AJAX
  • 8. PROGRESSIVE ENHANCEMENT: THE WRONG WAY sfFormExtraPlugin : sfWidgetFormJQueryDate sfWidgetFormJQueryAutocompleter sfWidgetFormTextareaTinyMCE
  • 9. PROGRESSIVE   ENHACEMENT: THE GOOD WAY Just use plain Javascript!
  • 10. AJAX: THE 4 STEPS Javascript catches an interaction with user, or with other browser events an XMLHttpRequest object send a request to server, without breaking the flow an XML (or other format) is returned by server Javascript decodes data from file and interacts with page
  • 11. AJAX: THE 4 STEPS Javascript catches an interaction with user, or with other browser events an XMLHttpRequest object send a request to server, without breaking the flow an XML (or other format) is returned by server Javascript decodes data from file and interacts with page
  • 12. AJAX: THE 4 STEPS Javascript catches an interaction with user, or with other browser events an XMLHttpRequest object send a request to server, without breaking the flow an XML (or other format) is returned by server Javascript decodes data from file and interacts with page
  • 13. AJAX: THE 4 STEPS Javascript catches an interaction with user, or with other browser events an XMLHttpRequest object send a request to server, without breaking the flow an XML (or other format) is returned by server Javascript decodes data from file and interacts with page
  • 14. AJAX: THE WRONG WAY sf 1.0: Javascript helper sf 1.4: sfJqueryPlugin <?php echo link_to_remote ('...'); echo jq_link_to_remote ('...');
  • 15. AJAX: THE GOOD WAY code as if Javascript wouldn't exist write your jQuery functions in the big $().ready() function do little adaptions to your controller write another view (tipically a JSON one)
  • 16. AJAX: THE GOOD WAY code as if Javascript wouldn't exist write your jQuery functions in the big $().ready() function do little adaptions to your controller write another view (tipically a JSON one)
  • 17. AJAX: THE GOOD WAY code as if Javascript wouldn't exist write your jQuery functions in the big $().ready() function do little adaptions to your controller write another view (tipically a JSON one)
  • 18. AJAX: THE GOOD WAY code as if Javascript wouldn't exist write your jQuery functions in the big $().ready() function do little adaptions to your controller write another view (tipically a JSON one)
  • 19. IN PRACTICE: LINK <?php // in the view echo link_to (' + ', ' cart_increase ', $item) $(' div#cart a.increase ').click(ajaxIncrease);
  • 20. var ajaxIncrease = function (e) {   $.ajax({     url:     this.href + ' ?sf_format=json ',     success: function (r) { increase(r, e.target); }   });   return false ; }; var increase = function (result, a) {   var $span = $(a).parents(' li ').find(' span.qty ');   var newqty = parseInt($span.text(), 10 ) + 1 ;   $span.empty().append(newqty);   $(' span#total ').empty();   $(' span#total ').append(result.total); };
  • 21. <?php // in the view // cartIncreaseSuccess.json.php use_helper(' Number ');   $arr = array(   ' total ' => format_currency($sf_user->getCartTotal(), ' EUR '), ); echo json_encode($arr);
  • 22. <?php // in the controller // actions.class.php public function executeCartIncrease(sfWebRequest $request) {   $this->product = $this->getRoute()->getProduct();   $this->getUser()->cartIncrease($this->product);   // was $this->redirect('@homepage');     $this->redirectUnless($request->isXmlHttpRequest(), ' @homepage '); }
  • 23. IN PRACTICE: FORM $(' div#filters form ').submit(ajaxFilter);
  • 24. var ajaxFilter = function(e) {   var $form = $(this);   $.ajax({     type: ' POST ',     url:  $form.attr(' action ') + ' ?sf_format=json ',     data: $form.serializeArray(),     success: showProducts   });   return false ; };
  • 25. Thanks! Massimiliano Arione @ garakkio blog.garak.it github.com/garak/sfjqec joind.in/talk/view/3034

Editor's Notes

  • #3: a brief history of my develeper evolution, with some stages: first  a plain procedural PHP developer, then some objects with PEAR, then full OOP with symfony, last (but not least) agile methods.
  • #4: is there anyone that DOES NOT know symfony? Well, symfony is a full-stack MVC framework written in PHP. This talk uses symfony for PHP code, but the core issue is not strictly related to symfony (so, you can just apply what we&apos;ll see to any framework, or generally to any PHP code)
  • #5: is there anyone that DOES NOT know jQuery? Weel, jQuery is a Javascript library.
  • #6: Here is a schema of MVC pattern, with separation between the three layes: Model, View, Controller
  • #7: Here is instead the separation concerning web pages: Conten, Presentation, Behavior
  • #8: What is behavior? It&apos;s mainly two things: progressive enhancement, and AJAX
  • #9: So, the progressive enhancement has been wrongly implemented in the past, with symfony. Those widgets, from sfFormExtraPlugin, do it the wrong way, by mixing php and javascript
  • #10: the right way is dead simple: just use plain javascript. Attach &amp;quot;ready&amp;quot; event and enhance.
  • #11: Here come the most interesting part: the famous AJAX. Let&apos;s see what AJAX is, in 4 simple steps.
  • #15: Like for behavior, also AJAX has been implemented in wrong ways in the past, with symfony. Helpers to do AJAX calls: again, this leads to php/js mixing (and to disregard separation between C and B)
  • #16: We can implement correctly AJAX in 4 steps.
  • #20: A practical example: a simple e-commerce site, with a link in the cart, to increase a quantity of an item in the cart itself.
  • #21: These two functions deals with AJAX request and with DOM manipulation after succeeded AJAX call.
  • #22: The added view is simply a JSON file, with needed data
  • #23: The only modify needed in the controller is not redirecting when request is coming from AJAX
  • #24: A similar approach is applied to forms
  • #25: This is just like the link example seen above, just with different point of tie (the form&apos;s &amp;quot;action&amp;quot; instead of link&apos;s &amp;quot;href&amp;quot;)
  • #26: That&apos;s it! You can find a complete symfony project on a github repository