SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
Streamlining Your
Applications with Web
    Frameworks
  Kings of Code ~ May 27th, 2008
What is a Web
              Framework?

• “...software framework that is designed to
  support the development of dynamic
  websites, Web applications and Web
  services.”
  
   
   
    
   
   
   
   - Wikipedia
What is a Web
         Framework?

• A set of tools and a way to organize them
• NOT an application
• An abstract base from which to build
• NOT a CMS
What is a Web
         Framework?

• Provide libraries for common tasks
• Provide structure and convention for your
  application code
• Promote best practices in application
  design/architecture
Continuum of Structure

CakePHP   CodeIgniter   Zend Framework

  More                         Less
Why Use a Framework?
• Lets you focus on what’s important
• The hard problems have already been
  solved by people smarter than you
• Benefits of community
• You (and your requirements) are not
  special
• Chances are, you already do
Why Cake?
• For a lot of people and a lot of reasons,
  Rails = FAIL
 • Difficult and expensive to deploy
 • Ahem! scaling...
 • Programmer availability
• PHP is still by far the #1 web language
Why Cake?
• “Oh Rasmus, why do you engage in this
  ‘virtual crap-flinging’? Can’t you lead by
  example like David Heinemeier Hansson?
  That guy is the height of maturity and an
  expert scalability guy.”

  “...look at the top 100 websites on the
  internet: about 40% of them are written in
  PHP and 0% of them are written in Rails.”
  
 
 
 
 
 
 
 
 
 
 - Terry Chay
Why Cake?
• Other PHP frameworks
 • Zend Framework
 • Symfony
 • PHP on Trax
 • CodeIgniter
An MVC Quickie
 Dispatcher    The Dispatcher requests the
              appropriate Controller/action,
                which interacts with the
                         Model

 Controller             Model




              The Controller then sends the
              results of its operations to the
   View
                view, where it is rendered
An MVC Quickie

• Primary: separation between Controller
  and View, to partition business logic and
  presentation
• Secondary: separation between data
  (Model) and Controller
An MVC Quickie
    A simple example
/* models/post.php */

class Post extends AppModel { }

/* controllers/posts_controller.php */
class PostsController extends AppController {

    function index() {
        // Get the data from the Model
        $posts = $this->paginate();

        // Send the data to the view
        $this->set(compact(‘posts’));
    }
}
<div class=quot;posts indexquot;>
<h2>Posts</h2>
<p><?=$paginator->counter(); ?></p>

<table cellpadding=quot;0quot; cellspacing=quot;0quot;>
<tr>

    <th><?=$paginator->sort('id'); ?></th>

    <th><?=$paginator->sort('title'); ?></th>

    <th><?=$paginator->sort('body'); ?></th>

    ...

    <th class=quot;actionsquot;>Actions</th>
</tr>
<? foreach ($posts as $post) { ?>

    <tr>

    
    <td><?=$post->id; ?></td>

    
    <td><?=$post->title; ?></td>

    
    <td><?=$post->body; ?></td>

    
    ....

    
    <td class=quot;actionsquot;>...</td>

    </tr>
<? } ?>
</table>

<div class=quot;pagingquot;>
<?=$paginator->prev('<< previous', array(), null, array('class' => 'disabled')); ?> |
<?=$paginator->numbers(); ?>
<?=$paginator->next('next >>', array(), null, array('class' => 'disabled')); ?>
</div>
An MVC Quickie
The Fun Stuff
Ajax!
• Normal Link:
  $html->link(‘Add Post’, ‘/posts/add’);


• Ajax Link:
  $ajax->link(‘Add Post’, ‘/posts/add’, array(
    ‘update’ => ‘addPostDiv’,
    ‘complete’ => ‘Effect.SlideDown(“addPostDiv”)’
  ));
REST & Resources!

• //   config/routes.php
Router::mapResources(“posts”);

Router::parseExtensions(“rss”, “js”);

• //   app_controller.php
var $components = array(“RequestHandler”);
REST & Resources!
// views/posts/xml/index.ctp
<posts>
<?php echo $xml->serialize($posts); ?>
</posts>
// views/posts/xml/view.ctp
<?php echo $xml->serialize($posts); ?>
REST & Resources!
// views/widgets/js/index.ctp
<?php echo $javascript->object($posts); ?>


// views/widgets/js/view.ctp
<?php echo $javascript->object($posts); ?>
REST & Resources!
GET /posts.xml HTTP/1.1
                            PostsController::index()
GET /posts/1.xml HTTP/1.1
                            PostsController::view(1)
POST /posts.xml HTTP/1.1
                            PostsController::add()
PUT /posts/1.xml HTTP/1.1
                            PostsController::edit(1)
DELETE /posts/1.xml HTTP/1.1
                          PostsController::delete(1)
REST & Resources!
POST /posts.xml HTTP/1.1
Host: www.example.org
Content-Type: text/xml; charset=utf-8

Content-Length: 67


<?xml version=“1.0”?>
<post title=“XML” body=“New Post from XML” />
The Future...

Mais conteúdo relacionado

Mais procurados

How do speed up web pages? CSS & HTML Tricks
How do speed up web pages? CSS & HTML TricksHow do speed up web pages? CSS & HTML Tricks
How do speed up web pages? CSS & HTML Tricks
Compare Infobase Limited
 
Going Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamGoing Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and Seam
Lincoln III
 
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
Jonathan Linowes
 

Mais procurados (20)

SPA using Rails & Backbone
SPA using Rails & BackboneSPA using Rails & Backbone
SPA using Rails & Backbone
 
Taking your Web App for a walk
Taking your Web App for a walkTaking your Web App for a walk
Taking your Web App for a walk
 
Taking Web Applications Offline
Taking Web Applications OfflineTaking Web Applications Offline
Taking Web Applications Offline
 
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
 
All you need to know about JavaScript loading and execution in the browser - ...
All you need to know about JavaScript loading and execution in the browser - ...All you need to know about JavaScript loading and execution in the browser - ...
All you need to know about JavaScript loading and execution in the browser - ...
 
How do speed up web pages? CSS & HTML Tricks
How do speed up web pages? CSS & HTML TricksHow do speed up web pages? CSS & HTML Tricks
How do speed up web pages? CSS & HTML Tricks
 
The Structure of Web Code: A Case For Polymer, November 1, 2014
The Structure of Web Code: A Case For Polymer, November 1, 2014The Structure of Web Code: A Case For Polymer, November 1, 2014
The Structure of Web Code: A Case For Polymer, November 1, 2014
 
Drupal8 + AngularJS
Drupal8 + AngularJSDrupal8 + AngularJS
Drupal8 + AngularJS
 
Web apps without internet
Web apps without internetWeb apps without internet
Web apps without internet
 
Build a Better Editing Experience with Advanced Custom Fields
Build a Better Editing Experience with Advanced Custom FieldsBuild a Better Editing Experience with Advanced Custom Fields
Build a Better Editing Experience with Advanced Custom Fields
 
PrettyFaces URLRewrite for Servlet & JavaEE @ Devoxx 2010
PrettyFaces URLRewrite for Servlet & JavaEE @ Devoxx 2010PrettyFaces URLRewrite for Servlet & JavaEE @ Devoxx 2010
PrettyFaces URLRewrite for Servlet & JavaEE @ Devoxx 2010
 
Pretty Bookmarkable JSF: PrettyFaces
Pretty Bookmarkable JSF: PrettyFacesPretty Bookmarkable JSF: PrettyFaces
Pretty Bookmarkable JSF: PrettyFaces
 
The Chaos Tools Suite
The Chaos Tools SuiteThe Chaos Tools Suite
The Chaos Tools Suite
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
 
Unobtrusive JavaScript
Unobtrusive JavaScriptUnobtrusive JavaScript
Unobtrusive JavaScript
 
Going Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and SeamGoing Above JSF 2.0 with RichFaces and Seam
Going Above JSF 2.0 with RichFaces and Seam
 
Leveraging the Chaos tool suite for module development
Leveraging the Chaos tool suite  for module developmentLeveraging the Chaos tool suite  for module development
Leveraging the Chaos tool suite for module development
 
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
Integrating Angular.js with Rails (Wicked Good Ruby Conf lightening talk)
 
Bookmarkable JSF: PrettyFaces
Bookmarkable JSF: PrettyFacesBookmarkable JSF: PrettyFaces
Bookmarkable JSF: PrettyFaces
 
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
 

Destaque

Destaque (20)

Webquest Template1
Webquest Template1Webquest Template1
Webquest Template1
 
So Many Feelings
So Many FeelingsSo Many Feelings
So Many Feelings
 
Graphing Review
Graphing ReviewGraphing Review
Graphing Review
 
Building A Better Website Governing 2008
Building A Better Website Governing 2008Building A Better Website Governing 2008
Building A Better Website Governing 2008
 
Presentacion Efecto Magnetico Tecno[1]
Presentacion Efecto Magnetico Tecno[1]Presentacion Efecto Magnetico Tecno[1]
Presentacion Efecto Magnetico Tecno[1]
 
Cuento Terminado Hombre Pobre Y Hombre Rico
Cuento Terminado Hombre Pobre Y Hombre RicoCuento Terminado Hombre Pobre Y Hombre Rico
Cuento Terminado Hombre Pobre Y Hombre Rico
 
Effectief gebruik powerpoint
Effectief gebruik powerpointEffectief gebruik powerpoint
Effectief gebruik powerpoint
 
Feudalismo
FeudalismoFeudalismo
Feudalismo
 
郭台銘情定舞蹈老師
郭台銘情定舞蹈老師郭台銘情定舞蹈老師
郭台銘情定舞蹈老師
 
Galchimia
GalchimiaGalchimia
Galchimia
 
Playa
PlayaPlaya
Playa
 
SABER HABITAR EL MON
SABER HABITAR EL MONSABER HABITAR EL MON
SABER HABITAR EL MON
 
مبادئ ادارة المناقشة
مبادئ ادارة المناقشةمبادئ ادارة المناقشة
مبادئ ادارة المناقشة
 
Opensource
OpensourceOpensource
Opensource
 
Tomar Notas
Tomar NotasTomar Notas
Tomar Notas
 
WordSoS
WordSoSWordSoS
WordSoS
 
唐家山堰塞湖目前處
唐家山堰塞湖目前處唐家山堰塞湖目前處
唐家山堰塞湖目前處
 
All
AllAll
All
 
oliver del pozo
oliver del pozooliver del pozo
oliver del pozo
 
Rubias
RubiasRubias
Rubias
 

Semelhante a Streamlining Your Applications with Web Frameworks

phpWebApp presentation
phpWebApp presentationphpWebApp presentation
phpWebApp presentation
Dashamir Hoxha
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
nicdev
 

Semelhante a Streamlining Your Applications with Web Frameworks (20)

AFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack EncoreAFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack Encore
 
Framework Presentation
Framework PresentationFramework Presentation
Framework Presentation
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
PHP on Windows
PHP on WindowsPHP on Windows
PHP on Windows
 
PHP on Windows
PHP on WindowsPHP on Windows
PHP on Windows
 
Api Design
Api DesignApi Design
Api Design
 
working with PHP & DB's
working with PHP & DB'sworking with PHP & DB's
working with PHP & DB's
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
 
PHP on Windows and on Azure
PHP on Windows and on AzurePHP on Windows and on Azure
PHP on Windows and on Azure
 
phpWebApp presentation
phpWebApp presentationphpWebApp presentation
phpWebApp presentation
 
Rest Vs Soap Yawn2289
Rest Vs Soap Yawn2289Rest Vs Soap Yawn2289
Rest Vs Soap Yawn2289
 
Asp.Net Mvc Dev Days09
Asp.Net Mvc Dev Days09Asp.Net Mvc Dev Days09
Asp.Net Mvc Dev Days09
 
Introduction to Web Development with Ruby on Rails
Introduction to Web Development with Ruby on RailsIntroduction to Web Development with Ruby on Rails
Introduction to Web Development with Ruby on Rails
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
JavaScript UI Architecture: Be all that you can be
JavaScript UI Architecture: Be all that you can beJavaScript UI Architecture: Be all that you can be
JavaScript UI Architecture: Be all that you can be
 
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyConsegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
 
ASP.NET - Ivan Marković
ASP.NET - Ivan MarkovićASP.NET - Ivan Marković
ASP.NET - Ivan Marković
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
ReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... YawnReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... Yawn
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Streamlining Your Applications with Web Frameworks

  • 1. Streamlining Your Applications with Web Frameworks Kings of Code ~ May 27th, 2008
  • 2. What is a Web Framework? • “...software framework that is designed to support the development of dynamic websites, Web applications and Web services.” - Wikipedia
  • 3. What is a Web Framework? • A set of tools and a way to organize them • NOT an application • An abstract base from which to build • NOT a CMS
  • 4. What is a Web Framework? • Provide libraries for common tasks • Provide structure and convention for your application code • Promote best practices in application design/architecture
  • 5. Continuum of Structure CakePHP CodeIgniter Zend Framework More Less
  • 6. Why Use a Framework? • Lets you focus on what’s important • The hard problems have already been solved by people smarter than you • Benefits of community • You (and your requirements) are not special • Chances are, you already do
  • 7. Why Cake? • For a lot of people and a lot of reasons, Rails = FAIL • Difficult and expensive to deploy • Ahem! scaling... • Programmer availability • PHP is still by far the #1 web language
  • 8. Why Cake? • “Oh Rasmus, why do you engage in this ‘virtual crap-flinging’? Can’t you lead by example like David Heinemeier Hansson? That guy is the height of maturity and an expert scalability guy.” “...look at the top 100 websites on the internet: about 40% of them are written in PHP and 0% of them are written in Rails.” - Terry Chay
  • 9. Why Cake? • Other PHP frameworks • Zend Framework • Symfony • PHP on Trax • CodeIgniter
  • 10. An MVC Quickie Dispatcher The Dispatcher requests the appropriate Controller/action, which interacts with the Model Controller Model The Controller then sends the results of its operations to the View view, where it is rendered
  • 11. An MVC Quickie • Primary: separation between Controller and View, to partition business logic and presentation • Secondary: separation between data (Model) and Controller
  • 12. An MVC Quickie A simple example /* models/post.php */ class Post extends AppModel { } /* controllers/posts_controller.php */ class PostsController extends AppController { function index() { // Get the data from the Model $posts = $this->paginate(); // Send the data to the view $this->set(compact(‘posts’)); } }
  • 13. <div class=quot;posts indexquot;> <h2>Posts</h2> <p><?=$paginator->counter(); ?></p> <table cellpadding=quot;0quot; cellspacing=quot;0quot;> <tr> <th><?=$paginator->sort('id'); ?></th> <th><?=$paginator->sort('title'); ?></th> <th><?=$paginator->sort('body'); ?></th> ... <th class=quot;actionsquot;>Actions</th> </tr> <? foreach ($posts as $post) { ?> <tr> <td><?=$post->id; ?></td> <td><?=$post->title; ?></td> <td><?=$post->body; ?></td> .... <td class=quot;actionsquot;>...</td> </tr> <? } ?> </table> <div class=quot;pagingquot;> <?=$paginator->prev('<< previous', array(), null, array('class' => 'disabled')); ?> | <?=$paginator->numbers(); ?> <?=$paginator->next('next >>', array(), null, array('class' => 'disabled')); ?> </div>
  • 16. Ajax! • Normal Link: $html->link(‘Add Post’, ‘/posts/add’); • Ajax Link: $ajax->link(‘Add Post’, ‘/posts/add’, array( ‘update’ => ‘addPostDiv’, ‘complete’ => ‘Effect.SlideDown(“addPostDiv”)’ ));
  • 17. REST & Resources! • // config/routes.php Router::mapResources(“posts”); Router::parseExtensions(“rss”, “js”); • // app_controller.php var $components = array(“RequestHandler”);
  • 18. REST & Resources! // views/posts/xml/index.ctp <posts> <?php echo $xml->serialize($posts); ?> </posts> // views/posts/xml/view.ctp <?php echo $xml->serialize($posts); ?>
  • 19. REST & Resources! // views/widgets/js/index.ctp <?php echo $javascript->object($posts); ?> // views/widgets/js/view.ctp <?php echo $javascript->object($posts); ?>
  • 20. REST & Resources! GET /posts.xml HTTP/1.1 PostsController::index() GET /posts/1.xml HTTP/1.1 PostsController::view(1) POST /posts.xml HTTP/1.1 PostsController::add() PUT /posts/1.xml HTTP/1.1 PostsController::edit(1) DELETE /posts/1.xml HTTP/1.1 PostsController::delete(1)
  • 21. REST & Resources! POST /posts.xml HTTP/1.1 Host: www.example.org Content-Type: text/xml; charset=utf-8 Content-Length: 67 <?xml version=“1.0”?> <post title=“XML” body=“New Post from XML” />