Slide 1

Slide 1 text

Zend Framework Overview Ben Ramsey Atlanta PHP May 4, 2006

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

What we will learn today • Zend Framework background • Framework components overview • Zend Framework roadmap • Setting up your environment • A “hello, world” example

Slide 4

Slide 4 text

Zend Framework background

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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!)

Slide 8

Slide 8 text

Project goals • Embrace collaboration and community to further advance PHP 5 programming • Positively contribute to the PHP 5 ecosystem and the PHP Collaboration Project

Slide 9

Slide 9 text

PHP Collaboration Project • a solid framework/development environment • enriched development tools (Eclipse) • best practices

Slide 10

Slide 10 text

Zend Framework License • BSD license (was originally similar to the PHP license with the “advertising clause”) • Located here: http://framework.zend.com/license/

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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/

Slide 14

Slide 14 text

Setting up your environment

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Set up your app structure • I recommend the following structure: / application/ controllers/ views/ library/ Zend/ www/ images/ styles/ .htaccess index.php

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Bootstrap file addScriptPath('../application/views'); Zend::register('view', $view); $controller = Zend_Controller_Front::getInstance() ->setControllerDirectory('../application/controllers') ->dispatch(); ?>

Slide 19

Slide 19 text

A “hello, world” example

Slide 20

Slide 20 text

Application structure • Zend Framework applications are controlled by instructions from the URI • Thus, consider the following: / /view/# /post/edit /post/save /post/remove/id/#

Slide 21

Slide 21 text

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/

Slide 22

Slide 22 text

IndexController.php title = 'Hiya'; $view->body = 'Hello, World!'; echo $view->render('hello.php'); } public function noRouteAction() { $this->_redirect('/'); } } ?>

Slide 23

Slide 23 text

Create our view • Create the following file (hello.php) and store in application/views/ <?php echo $this->escape($this->title); ?> escape($this->body); ?>

Slide 24

Slide 24 text

Say “hello” to everyone • Now, when a user accesses http://example.org/ or http://example.org/index, they’ll see the following: Hiya Hello, World!

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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