Zend Framework Overview

Document Sample
Zend Framework Overview Powered By Docstoc
					Zend Framework Overview
        Ben Ramsey
        Atlanta PHP
        May 4, 2006
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

• PHP enthusiast and advocate
  What we will learn today

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

• “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
         What is the Zend

• Like PEAR, it is a collection of classes that
 may be used together or separately

• Designed to be free from Intellectual Property
             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!)
            Project goals

• Embrace collaboration and community to
 further advance PHP 5 programming

• Positively contribute to the PHP 5 ecosystem
 and the PHP Collaboration Project
 PHP Collaboration Project

• a solid framework/development environment
• enriched development tools (Eclipse)
• best practices
  Zend Framework License

• BSD license (was originally similar to the PHP
 license with the “advertising clause”)

• Located here:
         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
  Framework components
Zend_Controller    Zend_Mime
Zend_Db            Zend_Pdf
Zend_Feed          Zend_Search
Zend_Filter        Zend_Service_Amazon
Zend_InputFilter   Zend_Service_Flickr
Zend_HttpClient    Zend_Service_Rest
Zend_Json          Zend_Service_Yahoo
Zend_Log           Zend_View
Zend_Mail          Zend_XmlRpc
 Zend Framework roadmap

• Currently seeking contributions: Zend_Auth,
 Zend_Acl, Zend_Feed_Builder, Zend_File,
 Zend_Http_Server, Zend_Locale,

• Stable release by Fall 2006?
• More info:
Setting up your environment

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

       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
                 Bootstrap file
/* this file lives at www/index.php */
include 'Zend.php';

function __autoload($class)

$view = new Zend_View;
Zend::register('view', $view);

$controller = Zend_Controller_Front::getInstance()
A “hello, world” example
     Application structure
• Zend Framework applications are controlled by
 instructions from the URI

• Thus, consider the following:
     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
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()
                 Create our view
• Create the following file (hello.php) and
 store in application/views/

 <title><?php echo $this->escape($this->title); ?></title>
 <?php echo $this->escape($this->body); ?>
      Say “hello” to everyone
• Now, when a user accesses http://example.org/
 or http://example.org/index, they’ll see the
 Hello, World!
    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
         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