Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Zend Framework Overview (Atlanta PHP May 2006)

Zend Framework Overview (Atlanta PHP May 2006)

For nearly two months, the Zend Framework has been the great talk of the PHP community. Just one day following Atlanta PHP's March meeting, the Zend Framework preview release was announced, and folks have been eager to download, play with it, and provide their feedback. At our May meeting, Ben Ramsey will take the Zend Framework for a test drive, outlining its current state, the direction it's heading, and rounding out the presentation with a quick tutorial on using the framework (code samples included). Finally, we'll start work on our group project, using the Zend Framework as a basis.

Ben Ramsey

May 04, 2006
Tweet

More Decks by Ben Ramsey

Other Decks in Programming

Transcript

  1. Who am I to discuss Zend? • I’m Ben Ramsey,

    and I have a blog • Professional PHP programmer for 5 years • Author of articles on PHP in International PHP Magazine and php|architect • Founding Principal of the PHP Security Consortium • PHP enthusiast and advocate
  2. What we will learn today • Zend Framework background •

    Framework components overview • Zend Framework roadmap • Setting up your environment • A “hello, world” example
  3. What is the Zend Framework? • “Zend Framework is a

    high quality and open source framework for developing Web Applications and Web Services.” • Zend’s answer to Enterprise-grade frameworks • Zend’s tool to promote PHP use in the Enterprise
  4. What is the Zend Framework? • Like PEAR, it is

    a collection of classes that may be used together or separately • Designed to be free from Intellectual Property disagreements
  5. Project goals • Provide a repository of high quality components

    that are actively supported • Provide a complete system for developing web applications powered by PHP 5 • Don’t change PHP -- it’s already a great platform (even without a framework!)
  6. Project goals • Embrace collaboration and community to further advance

    PHP 5 programming • Positively contribute to the PHP 5 ecosystem and the PHP Collaboration Project
  7. Zend Framework License • BSD license (was originally similar to

    the PHP license with the “advertising clause”) • Located here: http://framework.zend.com/license/
  8. More background • There is a contribution/proposal process • All

    contributors must sign the Contributor License Agreement • There are rigid standards for writing code • The framework is fairly easy to use
  9. Framework components overview Zend_Controller Zend_Db Zend_Feed Zend_Filter Zend_InputFilter Zend_HttpClient Zend_Json

    Zend_Log Zend_Mail Zend_Mime Zend_Pdf Zend_Search Zend_Service_Amazon Zend_Service_Flickr Zend_Service_Rest Zend_Service_Yahoo Zend_View Zend_XmlRpc
  10. Zend Framework roadmap • Currently seeking contributions: Zend_Auth, Zend_Acl, Zend_Feed_Builder,

    Zend_File, Zend_Http_Server, Zend_Locale, Zend_Session • Stable release by Fall 2006? • More info: http://framework.zend.com/roadmap/
  11. Requirements • PHP 5.0.4 with PDO extensions required; PHP 5.1

    recommended • Apache HTTPD server recommended for mod_rewrite rules, but not required • Download from: http://framework.zend.com/download
  12. Set up your app structure • I recommend the following

    structure: / application/ controllers/ views/ library/ Zend/ www/ images/ styles/ .htaccess index.php
  13. Server configuration • Create an .htaccess file with the following

    and place in www/ php_value include_path “../library” RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
  14. Bootstrap file <?php /* this file lives at www/index.php */

    include 'Zend.php'; function __autoload($class) { Zend::loadClass($class); } $view = new Zend_View; $view->addScriptPath('../application/views'); Zend::register('view', $view); $controller = Zend_Controller_Front::getInstance() ->setControllerDirectory('../application/controllers') ->dispatch(); ?>
  15. Application structure • Zend Framework applications are controlled by instructions

    from the URI • Thus, consider the following: / /view/# /post/edit /post/save /post/remove/id/#
  16. Create our controller • The framework dispatcher calls the index

    controller when someone access the root of the site (/), so we need to create one to handle these requests • Create IndexController.php in application/contorllers/
  17. IndexController.php <?php class IndexController extends Zend_Controller_Action { public function indexAction()

    { $view = Zend::registry('view'); $view->title = 'Hiya'; $view->body = 'Hello, World!'; echo $view->render('hello.php'); } public function noRouteAction() { $this->_redirect('/'); } } ?>
  18. Create our view • Create the following file (hello.php) and

    store in application/views/ <html> <head> <title><?php echo $this->escape($this->title); ?></title> </head> <body> <?php echo $this->escape($this->body); ?> </body> </html>
  19. Say “hello” to everyone • Now, when a user accesses

    http://example.org/ or http://example.org/index, they’ll see the following: <html> <head> <title>Hiya</title> </head> <body> Hello, World! </body> </html>
  20. What have we learned? • background on the framework •

    overview of components • quick look at the roadmap • how to set up your environment • said “hello” to the world
  21. For more information • Zend Framework: http://framework.zend.com/ • Zend Developer

    Zone: http://devzone.zend.com/ • Integrate Propel: http://devzone.zend.com/node/view/id/184 • Integrate Smarty: http://devzone.zend.com/node/view/id/156 • php|arch April 06: http://phparch.com/issue.php?mid=79 • Chris Shiflett’s tutorial: http://phparch/zftut • My blog: http://benramsey.com