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.

0c217b9a7dd0aa31ed40bd0f453727e1?s=128

Ben Ramsey
PRO

May 04, 2006
Tweet

Transcript

  1. Zend Framework Overview Ben Ramsey Atlanta PHP May 4, 2006

  2. 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
  3. What we will learn today • Zend Framework background •

    Framework components overview • Zend Framework roadmap • Setting up your environment • A “hello, world” example
  4. Zend Framework background

  5. 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
  6. 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
  7. 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!)
  8. Project goals • Embrace collaboration and community to further advance

    PHP 5 programming • Positively contribute to the PHP 5 ecosystem and the PHP Collaboration Project
  9. PHP Collaboration Project • a solid framework/development environment • enriched

    development tools (Eclipse) • best practices
  10. Zend Framework License • BSD license (was originally similar to

    the PHP license with the “advertising clause”) • Located here: http://framework.zend.com/license/
  11. 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
  12. 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
  13. 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/
  14. Setting up your environment

  15. 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
  16. Set up your app structure • I recommend the following

    structure: / application/ controllers/ views/ library/ Zend/ www/ images/ styles/ .htaccess index.php
  17. 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
  18. 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(); ?>
  19. A “hello, world” example

  20. Application structure • Zend Framework applications are controlled by instructions

    from the URI • Thus, consider the following: / /view/# /post/edit /post/save /post/remove/id/#
  21. 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/
  22. 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('/'); } } ?>
  23. 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>
  24. 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>
  25. 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
  26. 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