0
Zend Framework Introduction by Michelangelo van Dam
Who is Michelangelo van Dam ? <ul><li>Freelance PHP consultant with over 7 years of enterprise level PHP development exper...
What is Zend Framework ? <ul><li>a component based framework </li></ul><ul><ul><li>use the whole framework </li></ul></ul>...
Zend Framework map
Tools to build ZF applications <ul><li>IDE's </li></ul><ul><ul><li>Zend Studio 6.0 (“neon”) (www.zend.com) </li></ul></ul>...
A bit of theory... MVC <ul><li>model </li></ul><ul><ul><li>the model holds the business logic </li></ul></ul><ul><li>view ...
MVC in action
Setting up the virtualhost (Apache) <VirtualHost *:80> ServerName www.example.com ServerAlias example.com DocumentRoot /pa...
Directory structure app/ default/  <- the &quot;default&quot; application controllers/   <- here you define your controlle...
modify apache settings .htaccess RewriteEngine on RewriteRule !.(js|ico|gif|jpg|png|css)$ index.php
bootstrap file index.php /** * Setup controller */ $controller   =   Zend_Controller_Front::getInstance(); $controller ->s...
view script index/index.phtml <?php /** * Default home page view *  *  @author  Micehlangelo van Dam (michelangelo@in2it.b...
controller IndexController.php <?php /** * IndexController - The default controller class *  *  @author  Michelangelo van ...
that's it !
implementing Zend_Layout app/ default/ controllers/ models/ views/ helpers/ layouts/ layout.phtml <- here you define the s...
modifying bootstrap index.php /** * Setup controller */ $controller   =   Zend_Controller_Front::getInstance(); $controlle...
site layout with layout.phtml <?php  echo   '<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?>' ; ?> <?php   ech...
modifying index/index.phtml Hello, world!
modifying IndexController.php <?php /** * IndexController - The default controller class *  *  @author  Michelangelo van D...
Result is the same, but better
More information <ul><li>Zend Framework website  http://framework.zend.com </li></ul><ul><li>Zend Developer Zone  http://d...
Further reading <ul><li>Guide to Programming with Zend Framework </li></ul><ul><li>written by: Cal Evans </li></ul><ul><li...
Additional notes <ul><li>This presentation can be found on SlideShare </li></ul><ul><li>http://www.slideshare.net/DragonBe...
Thank you... Any Questions ???
Upcoming SlideShare
Loading in...5
×

Introduction to Zend Framework

16,755

Published on

An introduction to writing a simple Zend Framework MVC application

Published in: Technology
4 Comments
14 Likes
Statistics
Notes
No Downloads
Views
Total Views
16,755
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
696
Comments
4
Likes
14
Embeds 0
No embeds

No notes for slide

Transcript of "Introduction to Zend Framework"

  1. 1. Zend Framework Introduction by Michelangelo van Dam
  2. 2. Who is Michelangelo van Dam ? <ul><li>Freelance PHP consultant with over 7 years of enterprise level PHP development experience. </li></ul><ul><li>Started using Zend Framework in 2007 and contributes to this framework for Zend_Ldap. </li></ul><ul><li>web: http://www.in2it.be </li></ul><ul><li>blog: http://dragonbe.blogspot.com </li></ul><ul><li>e-mail: dragonbe [at] google mail </li></ul><ul><li>twitter: http://twitter.com/DragonBe </li></ul>
  3. 3. What is Zend Framework ? <ul><li>a component based framework </li></ul><ul><ul><li>use the whole framework </li></ul></ul><ul><ul><li>pick what you need, drop the rest </li></ul></ul><ul><li>implementing the MVC-paradigm </li></ul><ul><li>simplicity and object oriented best practices </li></ul><ul><li>corporate friendly license (new BSD license) </li></ul><ul><li>a very tested agile code base </li></ul><ul><li>modify code by extending components </li></ul>
  4. 4. Zend Framework map
  5. 5. Tools to build ZF applications <ul><li>IDE's </li></ul><ul><ul><li>Zend Studio 6.0 (“neon”) (www.zend.com) </li></ul></ul><ul><ul><ul><li>fully supported by Zend </li></ul></ul></ul><ul><ul><ul><li>integration of Zend Framework in IDE </li></ul></ul></ul><ul><ul><li>Komodo IDE (www.activestate.com) </li></ul></ul><ul><li>Text editors </li></ul><ul><ul><li>vi(m) </li></ul></ul><ul><ul><li>textpad </li></ul></ul><ul><ul><li>notepad </li></ul></ul>
  6. 6. A bit of theory... MVC <ul><li>model </li></ul><ul><ul><li>the model holds the business logic </li></ul></ul><ul><li>view </li></ul><ul><ul><li>creates the presentation layer </li></ul></ul><ul><li>controller </li></ul><ul><ul><li>defines actions to be executed </li></ul></ul>
  7. 7. MVC in action
  8. 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>
  9. 9. Directory structure app/ default/ <- the &quot;default&quot; 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
  10. 10. modify apache settings .htaccess RewriteEngine on RewriteRule !.(js|ico|gif|jpg|png|css)$ index.php
  11. 11. bootstrap file index.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(); require_once 'Zend/Controller/Front.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() );
  12. 12. view script index/index.phtml <?php /** * Default home page view * * @author Micehlangelo van Dam (michelangelo@in2it.be) * @version $Id$ */ echo '<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?>' ; ?> <! DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot; > < html xmlns = &quot;http://www.w3.org/1999/xhtml&quot; > < head > < meta http-equiv = &quot;Content-Type&quot; content = &quot;text/html; charset=UTF-8&quot; /> < title > New Zend Framework Project </ title > </ head > < body > Hello, world! </ body > </ html >
  13. 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 } }
  14. 14. that's it !
  15. 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
  16. 16. modifying bootstrap index.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(); require_once 'Zend/Controller/Front.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() );
  17. 17. site layout with layout.phtml <?php echo '<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?>' ; ?> <?php echo $this ->doctype( 'XHTML1_TRANSITIONAL' ); ?> < html xmlns = &quot;http://www.w3.org/1999/xhtml&quot; > < 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 >
  18. 18. modifying index/index.phtml Hello, world!
  19. 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' ); } }
  20. 20. Result is the same, but better
  21. 21. More information <ul><li>Zend Framework website http://framework.zend.com </li></ul><ul><li>Zend Developer Zone http://devzone.zend.com </li></ul><ul><li>ZFTutorials forum http://www.zftutorials.com </li></ul><ul><li>Blogs </li></ul><ul><ul><li>Matthew Weier O'Phinney: http://weierophinney.net/matthew </li></ul></ul><ul><ul><li>Cal Evans: http://blog.calevans.com </li></ul></ul><ul><ul><li>Andries Seutens: http://andries.systray.be/blog </li></ul></ul><ul><ul><li>Rob Allen: http://akrabat.com </li></ul></ul>
  22. 22. Further reading <ul><li>Guide to Programming with Zend Framework </li></ul><ul><li>written by: Cal Evans </li></ul><ul><li>published by: php|arch ( http://phparch.com ) </li></ul><ul><li>Zend Framework in Action </li></ul><ul><li>written by: Rob Allen, Nick Lo, Steven Brown </li></ul><ul><li>published by: Manning Publications ( http://manning.com ) </li></ul>
  23. 23. Additional notes <ul><li>This presentation can be found on SlideShare </li></ul><ul><li>http://www.slideshare.net/DragonBe/introduction-to-zend-framework/ </li></ul><ul><li>On IRC ( irc.freenode.net ) you can go to #zftalk to chat about Zend Framework </li></ul><ul><li>Team up with the Belgian PHP Community on http://phpbelgium.be </li></ul>
  24. 24. Thank you... Any Questions ???
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×