Introduction to Zend Framework
Upcoming SlideShare
Loading in...5
×
 

Introduction to Zend Framework

on

  • 21,905 views

An introduction to writing a simple Zend Framework MVC application

An introduction to writing a simple Zend Framework MVC application

Statistics

Views

Total Views
21,905
Views on SlideShare
21,339
Embed Views
566

Actions

Likes
15
Downloads
689
Comments
4

21 Embeds 566

http://mauriziostorani.wordpress.com 311
http://www.dragonbe.com 103
http://www.slideshare.net 77
http://onwebdev.blogspot.com 16
http://www.planet-php.net 12
http://blog.gabrieleromanato.com 10
http://dragonbe.blogspot.com 9
http://www.phpzend.com.ar 7
http://www.linkedin.com 6
http://fachak.com 2
http://www.planet-php.org 2
http://localhost 2
http://feeds.feedburner.com 1
http://sireesh.blog.co.in 1
http://thearakanesemeetingpoint.appspot.com 1
http://forum.fcicafe.com 1
http://209.85.137.132 1
http://209.85.129.132 1
http://translate.googleusercontent.com 1
http://ple2.tumblr.com 1
http://safe.tumblr.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

14 of 4 Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • nice. Visit this url
    http://codemustangs.wordpress.com/2012/08/15/example-to-start-working-with-zend-framework/
    Are you sure you want to
    Your message goes here
    Processing…
  • i have really learnt a lot from this..this is my first into to mvc framework. thanks.
    Are you sure you want to
    Your message goes here
    Processing…
  • The reason why I don't use the auto load feature in my slides is to indicate the components that are being used. Of course you can enable auto loading and tweak other features as well, but that's a matter of personal taste.
    Are you sure you want to
    Your message goes here
    Processing…
  • Very cool! I've only messed with the Zend_Pdf classes in the framework so far. But, the layout & MVC stuff you show here looks pretty cool. I'll have to give it a try.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Introduction to Zend Framework Introduction to Zend Framework Presentation Transcript

    • Zend Framework Introduction by Michelangelo van Dam
    • 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
    • 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
    • Zend Framework map
    • 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
    • A bit of theory... MVC
      • model
        • the model holds the business logic
      • view
        • creates the presentation layer
      • controller
        • defines actions to be executed
    • MVC in action
    • 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>
    • 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
    • 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 ->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() );
    • 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 >
    • 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 } }
    • that's it !
    • 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
    • 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() );
    • 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 >
    • modifying index/index.phtml Hello, world!
    • 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' ); } }
    • Result is the same, but better
    • 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
    • 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 )
    • 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
    • Thank you... Any Questions ???