Your SlideShare is downloading. ×
0
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Zend - Installation And Sample Project Creation

5,361

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
5,361
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
76
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Compare Infobase Ltd
  • Transcript

    • 1. Zend Framework Introduction by Susheel Kumar Sharma
    • 2. Zend Framework Introduction
      • Open Source Framework
      • 100% Object-Oriented Code
      • Use-At-Will
      •   MVC Pattern
    • 3. MVC
      • Model - data, web services, feeds, etc.
      • View - The display returned to the user.
      • Controller - Manages the request environment, and determines what happens.
    • 4. MVC Cont..
    • 5. MVC Cont…
      • Controller <-> View Controller and View can interact
      • Controller <-> Model Controller can pull data from the model for decisioning, or push data to the model
      • View <- Model View can access the model to retrieve data, but not write to it.
    • 6. Installation Zend Framework Cont..
      • By Installing Zend Server
      • Manual Installation
    • 7. Installation Zend Framework Cont..
      • Manual Installation
      • 1.Check php is available from any directory
      • C:Userscompare>php –I
      • 2.If not, set path for php.exe in System Environment Variable
      • a)Find your php installation directory - This can generally be found in one of the following places:
      • C:php
      • C:xamppphp
      • b)Go to -> My Computer -> (Right Click)Properties
      • -> Advanced -> Environment Variables -> System Variables -> (Select)Path -> Edit -> Variable Value(Paste) -> Ok
    • 8. Installation Zend Framework Cont.. 3.Copy zf.bat, zf.php from ZendFrameworkbin and paste zf.bat, zf.php to C:php or C:xamppphp 4.Set up Zend Framework library to system PHP include_path a) Open php.ini in an editor b) Find include_path c) Add Zend Framework library e.g. include_path = &quot;.;G:xamppphppear;G:dataZendFrameworklibrary“ 5. Run command C:Userscompare>zf show version Zend Framework Version: 1.11.2
    • 9. Create Project 1.Go to directory where you want to create project e.g. C:Userscompare>cd .. C:Users>cd .. C:>G: G:>cd xampphtdocs G:xampphtdocs> 2. Run command G:xampphtdocs> zf create project trainingtestproject Creating project at G:/xampp/htdocs/trainingtestproject Note: This command created a web project, for more information setting up your V HOST, please see docs/README
    • 10. Create Project Cont.. 3. Project directory structure trainingtestproject |-- application |   |-- Bootstrap.php |   |-- configs |   |   `-- application.ini |   |-- controllers |   |   |-- ErrorController.php |   |   `-- IndexController.php |   |-- models |   `-- views |       |-- helpers |       `-- scripts |           |-- error |           |   `-- error.phtml |           `-- index |               `-- index.phtml |-- library |-- public |   |-- .htaccess |   `-- index.php `-- tests     |-- application     |   `-- bootstrap.php     |-- library     |   `-- bootstrap.php     `-- phpunit.xml
    • 11. Create Project Cont.. 4.Copy Zend directory from ZendFrameworklibraryZend and paste to trainingtestprojectlibraryZend(Optional)
    • 12. Main Artifacts
      • Bootstrap
      • Configuration
      • Action Controllers
      • Views
    • 13. The Bootstrap
      • Bootstrap class defines what resources and components to initialize
      • By default, Zend Framework's Front Controller is initialized
      • It uses the application/controllers/ as the default directory in which to look for action controllers
      • The class looks like the following:
      • // application/Bootstrap.php
      • class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
      • {
      • }
    • 14. Configuration
      • Zend Framework is itself configuration less, need to configure application.
      • The default configuration is placed in application/configs/application.ini
      • Contains some basic directives for setting PHP environment 
      • It looks as follows:
    • 15. Configuration Cont.. ; application/configs/application.ini [production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 includePaths.library = APPLICATION_PATH &quot;/../library&quot; bootstrap.path = APPLICATION_PATH &quot;/Bootstrap.php&quot; bootstrap.class = &quot;Bootstrap&quot; appnamespace = &quot;Application&quot; resources.frontController.controllerDirectory = APPLICATION_PATH &quot;/controllers&quot; resources.frontController.params.displayExceptions = 0 [staging : production]   [testing : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1
    • 16. Action Controllers
      • action controllers contain application workflow, do mapping requests to the appropriate models and views.
      • action controller should have one or more methods ending in “Action”
      •   methods may then be requested via the web
      • Zend Framework URLs follow the schema /controller/action
      • &quot;controller&quot; maps to the action controller name (minus the &quot;Controller&quot; suffix) and &quot;action&quot; maps to an action method (minus the &quot;Action&quot; suffix)
      • need an IndexController, which is a fallback controller and which also serves the home page of the site
      • ErrorController, which is used to indicate things such as HTTP 404 errors (controller or action not found) and HTTP 500 errors (application errors)
    • 17. Action Controllers Cont..
      • The default IndexController is as follows:
      • // application/controllers/IndexController.php
      • class IndexController extends Zend_Controller_Action
      • {
      •      public function init()
      •      {
      •          /* Initialize action controller here */
      •      }
      •      public function indexAction()
      •      {
      •          // action body
      •      }
      • }
    • 18. Action Controllers Cont..
      • ErrorController is as follows:
      • // application/controllers/ErrorController.php
      • class ErrorController extends Zend_Controller_Action
      • {
      •      public function errorAction()
      •      {
      •          $errors = $this->_getParam('error_handler');
      •          switch ($errors->type) {
      •              case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
      •              case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLE
      • R:
      •             case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
      •                  // 404 error -- controller or action not found
      •                  $this->getResponse()->setHttpResponseCode(404);
      •                  $this->view->message = 'Page not found';
      •                  break;
    • 19.              default:                  // application error                  $this->getResponse()->setHttpResponseCode(500);                  $this->view->message = 'Application error';                  break;          }           $this->view->exception = $errors->exception;          $this->view->request   = $errors->request;      } }
    • 20. Views
      • Written in plain old PHP
      • View scripts are placed in application/views/scripts/
      • They are further categorized using the controller names
      • We have an IndexController and an ErrorController
      • Thus we have corresponding  index/ and error/ 
      • subdirectories within view scripts directory
      • We thus have the view scripts index/index.phtml 
      • and error/error.phtml
      • The following is what we install by default for the index/index.phtml view script:
    • 21. Views Cont.. <!-- application/views/scripts/index/index.phtml --> <style>      a: link ,     a:visited{color: #0398CA;}     span#zf-name{color: #91BE3F;}     div#welcome{color: #FFFFFF;background-image: url(http://framework.zend.com/images/bkg_header.jpg); width:  600px;height: 400px;border: 2px solid #444444; overflow: hidden;text-align: center;}     div#more-information{background-image: url(http://framework.zend.com/images/bkg_body-bottom.gif);         height: 100%;}   </style> <div id=&quot;welcome&quot;>     <h1>Welcome to the <span id=&quot;zf-name&quot;>Zend Framework!</span><h1 />     <h3>This is your project's main page<h3 />
    • 22.     <div id=&quot;more-information&quot;>         <p>             <img src=&quot;http://framework.zend.com/images/PoweredBy_ZF_4LightBG.png&quot; />         </p>          <p>             Helpful Links: <br />             <a href=&quot;http://framework.zend.com/&quot;>Zend Framework Website</a> |             <a href=&quot;http://framework.zend.com/manual/en/&quot;>Zend Framework                 Manual</a>         </p>     </div> </div>
    • 23. Views Cont..
      • The error/error.phtml view script :
      • <!-- application/views/scripts/error/error.phtml -->
      • <!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;;
      •      &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
      • <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>Zend Framework Default Application</title>
      • </head>
      • <body>
      •   <h1>An error occurred</h1>
      •   <h2><?php  echo  $this->message ?></h2>
      •     <?php if ('development' == $this->env): ?>
      •    <h3>Exception information:</h3>
      •   <p>
      •  
    • 24.     <b>Message:</b> <?php  echo  $this->exception->getMessage() ?>   </p>    <h3>Stack trace:</h3>   <pre><?php  echo  $this->exception->getTraceAsString() ?>   </pre>    <h3>Request Parameters:</h3>   <pre><?php  echo   var _export ($this->request->getParams(), 1) ?>   </pre>    <?php endif ?>   </body> </html>
    • 25. Create a virtual host(Optional)
      • Open httpd.conf file in any editor,
      • Some common locations: /etc/httpd/httpd.conf (Fedora, RHEL, and others), C:Program FilesZendApache2conf (Zend Server on Windows machines)/ G:xamppapacheconf
      •   First, ensure that the NameVirtualHost is defined; set it to a value of &quot;*:80&quot;
      • define a virtual host:
      • <VirtualHost *:80>
      •      ServerName quickstart.local
      •      DocumentRoot /path/to/quickstart/public
      •      SetEnv APPLICATION_ENV &quot;development&quot;
      •     <Directory /path/to/quickstart/public>
      •          DirectoryIndex index.php
      •          AllowOverride All
      •          Order allow,deny
      •          Allow from all
      •     </Directory>
      • </VirtualHost>
    • 26. Create a virtual host(Optional) Cont.. <VirtualHost *:80>      ServerName  trainingtestproject.local      DocumentRoot /path/to/quickstart/public      SetEnv APPLICATION_ENV &quot;development&quot;     <Directory /path/to/quickstart/public>          DirectoryIndex index.php          AllowOverride All          Order allow,deny          Allow from all     </Directory> </VirtualHost>
    • 27. Create a virtual host(Optional) Cont..
      •   DocumentRoot setting specifies the public subdirectory of project; this means that only files under that directory can ever be served directly by the server
      • AllowOverride, Order, and Allow directives; these are to allow to use htacess files within project
      • SetEnv directive is setting an environment variable for virtual host; this variable will be picked up in the index.php and used to set the APPLICATION_ENV constant for our Zend Framework application
      • Add an entry in hosts file located at : On *nix-like systems, this is usually /etc/hosts;
      • On windows : C:WINDOWSsystem32driversetc
      • 127.0.0.1 trainingtestproject.local
    • 28. Reference : http://framework.zend.com/ http://framework.zend.com/manual/en/
    • 29.  

    ×