Slideshare.net (beta)

 
Post: 
Myspace Hi5 Friendster Xanga LiveJournal Facebook Blogger Tagged Typepad Freewebs BlackPlanet gigya icons



All comments

Add a comment on Slide 1

If you have a SlideShare account, login to comment; else you can comment as a guest


Showing 1-50 of 5 (more)

Introduction to Zend Framework

From DragonBe, 2 months ago

An introduction to writing a simple Zend Framework MVC application

1158 views  |  2 comments  |  3 favorites  |  37 downloads  |  4 embeds (Stats)
 

Groups/Events

 
 

Privacy InfoNew!

This slideshow is Public

 
CC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs License
Embed in your blog
Embed (wordpress.com)
custom

Slideshow Statistics
Total Views: 1158
on Slideshare: 1118
from embeds: 40* * Views from embeds since 21 Aug, 07

Slideshow transcript

Slide 1: Zend Framework Introduction by Michelangelo van Dam 1

Slide 2: Who is Michelangelo van Dam ? Freelance PHP consultant with over 7 years of enterprise level PHP development experience. Started using Zend Framework in 2007 and contributes to this framework for Zend_Ldap. web: http://www.in2it.be blog: http://dragonbe.blogspot.com e-mail: dragonbe [at] google mail twitter: http://twitter.com/DragonBe 2

Slide 3: What is Zend Framework ? ● a component based framework – use the whole framework – pick what you need, drop the rest ● implementing the MVC-paradigm ● simplicity and object oriented best practices ● corporate friendly license (new BSD license) ● a very tested agile code base ● modify code by extending components 3

Slide 4: Zend Framework map 4

Slide 5: Tools to build ZF applications ● IDE's – Zend Studio 6.0 (“neon”) (www.zend.com) ● fully supported by Zend ● integration of Zend Framework in IDE – Komodo IDE (www.activestate.com) ● Text editors – vi(m) – textpad – notepad 5

Slide 6: A bit of theory... MVC ● model – the model holds the business logic ● view – creates the presentation layer ● controller – defines actions to be executed 6

Slide 7: MVC in action 7

Slide 8: Setting up the virtualhost (Apache) <VirtualHost *:80> ServerName www.example.com ServerAlias example.com DocumentRoot /path/to/example.com/htdocs <Directory /path/to/example.com/htdocs> Options Indexes FollowSymlinks AllowOverride All Order allow,deny Allow from all DirectoryIndex index.php </Directory> SetEnv ENVPHP localhost ErrorLog /path/to/logs/example.com-error_log CustomLog /path/to/logs/example.com-access_log common </VirtualHost> 8

Slide 9: Directory structure app/ default/ <- the "default" application controllers/ <- here you define your controllers ErrorController.php IndexController.php models/ <- this is where your business logic is put views/ <- everything for presentations is put here helpers/ scripts/ index/ index.phtml error/ index.phtml library/ Zend/ <- this is the Zend Framework library htdocs/ <- this is where your bootstrap file is located images/ scripts/ styles/ .htaccess index.php 9

Slide 10: modify apache settings .htaccess RewriteEngine on RewriteRule !.(js|ico|gif|jpg|png|css)$ index.php 10

Slide 11: bootstrap file index.php <?php /** * My new Zend Framework project * * @author Michelangelo van Dam (michelangelo@in2it.be) * @version $Id$ */ set_include_path('.' . PATH_SEPARATOR . '../library' . PATH_SEPARATOR . '../application/default/models/' . PATH_SEPARATOR . get_include_path()); require_once 'Zend/Controller/Front.php'; /** * Setup controller */ $controller = Zend_Controller_Front::getInstance(); $controller->setControllerDirectory('../application/default/controllers'); $controller->throwExceptions(false); // should be turned on in development time // run! $controller->dispatch(); 11

Slide 12: view script index/index.phtml <?php /** * Default home page view * * @author Micehlangelo van Dam (michelangelo@in2it.be) * @version $Id$ */ echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>New Zend Framework Project</title> </head> <body> Hello, world! </body> </html> 12

Slide 13: controller IndexController.php <?php /** * IndexController - The default controller class * * @author Michelangelo van Dam (michelangelo@in2it.be) * @version $Id$ */ require_once 'Zend/Controller/Action.php'; class IndexController extends Zend_Controller_Action { /** * The default action - show the home page */ public function indexAction() { // TODO Auto-generated IndexController::indexAction() action } } 13

Slide 14: that's it ! 14

Slide 15: implementing Zend_Layout app/ default/ controllers/ models/ views/ helpers/ layouts/ layout.phtml <- here you define the site layout scripts/ index/ error/ library/ Zend/ htdocs/ images/ scripts/ styles/ .htaccess index.php 15

Slide 16: modifying bootstrap index.php <?php /** * My new Zend Framework project * * @author Michelangelo van Dam (michelangelo@in2it.be) * @version $Id$ */ set_include_path('.' . PATH_SEPARATOR . '../library' . PATH_SEPARATOR . '../application/default/models/' . PATH_SEPARATOR . get_include_path()); require_once 'Zend/Controller/Front.php'; /** * Setup controller */ $controller = Zend_Controller_Front::getInstance(); $controller->setControllerDirectory('../application/default/controllers'); $controller->throwExceptions(false); // should be turned on in development time // We enable Zend_Layout Zend_Layout::startMvc(array('layoutPath' => '../app/views/layouts')); // run! $controller->dispatch(); 16

Slide 17: site layout with layout.phtml <?php echo '<?xml version="1.0" encoding="UTF-8" ?>';?> <?php echo $this->doctype('XHTML1_TRANSITIONAL'); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php echo $this->headMeta()->appendHttpEquiv( 'Content-Type', 'text/html; Charset=UTF-8' ); ?> <?php echo $this->headTitle(); ?> </head> <body> <?php echo $this->layout()->content; ?> </body> </html> 17

Slide 18: modifying index/index.phtml Hello, world! 18

Slide 19: modifying IndexController.php <?php /** * IndexController - The default controller class * * @author Michelangelo van Dam (michelangelo@in2it.be) * @version $Id$ */ require_once 'Zend/Controller/Action.php'; class IndexController extends Zend_Controller_Action { /** * The default action - show the home page */ public function indexAction() { $this->headTitle('New Zend Framework Application'); } } 19

Slide 20: Result is the same, but better 20

Slide 21: More information ● Zend Framework website http://framework.zend.com ● Zend Developer Zone http://devzone.zend.com ● ZFTutorials forum http://www.zftutorials.com ● Blogs – Matthew Weier O'Phinney: http://weierophinney.net/matthew – Cal Evans: http://blog.calevans.com – Andries Seutens: http://andries.systray.be/blog – Rob Allen: http://akrabat.com 21

Slide 22: Further reading Guide to Programming with Zend Framework written by: Cal Evans published by: php|arch (http://phparch.com) Zend Framework in Action written by: Rob Allen, Nick Lo, Steven Brown published by: Manning Publications (http://manning.com) 22

Slide 23: Additional notes This presentation can be found on SlideShare http://www.slideshare.net/DragonBe/introduction-to-zend-framework/ On IRC (irc.freenode.net) you can go to #zftalk to chat about Zend Framework Team up with the Belgian PHP Community on http://phpbelgium.be 23

Slide 24: Thank you... Any Questions ??? 24