Streamlining Your Applications with Web Frameworks

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Streamlining Your Applications with Web Frameworks - Presentation Transcript

    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=\"posts index\"> <h2>Posts</h2> <p><?=$paginator->counter(); ?></p> <table cellpadding=\"0\" cellspacing=\"0\"> <tr> <th><?=$paginator->sort('id'); ?></th> <th><?=$paginator->sort('title'); ?></th> <th><?=$paginator->sort('body'); ?></th> ... <th class=\"actions\">Actions</th> </tr> <? foreach ($posts as $post) { ?> <tr> <td><?=$post->id; ?></td> <td><?=$post->title; ?></td> <td><?=$post->body; ?></td> .... <td class=\"actions\">...</td> </tr> <? } ?> </table> <div class=\"paging\"> <?=$paginator->prev('<< previous', array(), null, array('class' => 'disabled')); ?> | <?=$paginator->numbers(); ?> <?=$paginator->next('next >>', array(), null, array('class' => 'disabled')); ?> </div>
    14. An MVC Quickie
    15. The Fun Stuff
    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” />
    22. The Future...

    + guestf7bc30guestf7bc30, 2 years ago

    custom

    1520 views, 1 favs, 0 embeds more stats

    Presentation by Nate Abele from CakePHP about web d more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1520
      • 1520 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 66
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories