Uploaded on

What is Zend Framework? …

What is Zend Framework?
Getting and Installing Zend Framework
MVC overview
Quick Start to developing applications using Zend Framework's

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
11,911
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
23
Comments
0
Likes
1

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

Transcript

  • 1. Zend Framework
  • 2. • What is Zend Framework?• Getting and Installing Zend Framework• MVC overview• Quick Start to developing applications using Zend Frameworks
  • 3. What is Zend Framework?• PHP 5 library for web development productivity• Free, Open source• Class library – fully OOP• Documentation – in many languages• Quality & testing – fully unit tested
  • 4. Whats in Zend Framework?
  • 5. Requirments• PHP 5.1.4• Web server• Standard installation• Commonly no additional extensions needed
  • 6. quickstart quickstartThe |-- application |-- application || |-- Bootstrap.php |-- Bootstrap.php || |-- configs |-- configs || || `-- application.inidirectory `-- application.ini || |-- controllers |-- controllers || || |-- ErrorController.php |-- ErrorController.php || || `-- IndexController.php `-- IndexController.phptree || |-- models |-- models || `-- views || `-- views |-- helpers |-- helpers || `-- scripts `-- scripts || |-- error |-- error || || `-- error.phtml `-- error.phtml || `-- index `-- index || `-- index.phtml `-- index.phtml |-- library |-- library |-- public |-- public || `-- index.php `-- index.php `-- tests `-- tests |-- application |-- application || `-- bootstrap.php `-- bootstrap.php |-- library |-- library || `-- bootstrap.php `-- bootstrap.php `-- phpunit.xml `-- phpunit.xml 14 directories, 10 files 14 directories, 10 files
  • 7. Sample INI config[production] [production]app.name = "Foo!" app.name = "Foo!"db.adapter = "Pdo_Mysql" db.adapter = "Pdo_Mysql"db.params.username = "foo" db.params.username = "foo"db.params.password = "bar" db.params.password = "bar"db.params.dbname = "foodb" db.params.dbname = "foodb"db.params.host = "127.0.0.1" db.params.host = "127.0.0.1"[testing : production] [testing : production]db.adapter = "Pdo_Sqlite" db.adapter = "Pdo_Sqlite"db.params.dbname = APPLICATION_PATH "/data/test.db" db.params.dbname = APPLICATION_PATH "/data/test.db"
  • 8. Getting and InstallingZend Framework
  • 9. Always found at:http://framework.zend.com /download/latest
  • 10. Unzip/Untar• Use CLI: % tar xzf ZendFramework-1.9.2- minimal.tar.gz % unzip ZendFramework-1.9.2- minimal.zip• Or use a GUI file manager
  • 11. Add to yourinclude_path <?php <?php set_include_path(implode(PATH_SEPARATOR, array( set_include_path(implode(PATH_SEPARATOR, array( ., ., /home/matthew/zf/library, /home/matthew/zf/library, get_include_path(), get_include_path(), ))); )));
  • 12. Step 1:Create the project
  • 13. Locate the zfModel in the Controller Using the utility In bin/zf.sh of bin/zf.bat of your ZF install (choose based on your OS) Place bin/ in your path, or create an alias on your path: alias zf=/path/to/bin/zf.sh
  • 14. Create the project # Unix: # Unix: % zf.sh create project quickstart % zf.sh create project quickstart # DOS/Windows: # DOS/Windows: C:> zf.bat create project quickstart C:> zf.bat create project quickstart
  • 15. Create a vhost<VirtualHost *:80> <VirtualHost *:80> ServerAdmin you@atyour.tld ServerAdmin you@atyour.tld DocumentRoot /abs/path/to/quickstart/public DocumentRoot /abs/path/to/quickstart/public ServerName quickstart ServerName quickstart <Directory /abs/path/to/quickstart/public> <Directory /abs/path/to/quickstart/public> DirectoryIndex index.php DirectoryIndex index.php AllowOverride All AllowOverride All Order allow,deny Order allow,deny Allow from all Allow from all </Directory> </Directory></VirtualHost> </VirtualHost>
  • 16. Fire up your browser!
  • 17. Configuration [production] [production] phpSettings.display_startup_errors == 00 phpSettings.display_startup_errors phpSettings.display_errors == 00 phpSettings.display_errors includePaths.library == APPLICATION_PATH "/../library" includePaths.library APPLICATION_PATH "/../library" bootstrap.path == APPLICATION_PATH "/Bootstrap.php" bootstrap.path APPLICATION_PATH "/Bootstrap.php" bootstrap.class == "Bootstrap" bootstrap.class "Bootstrap" resources.frontController.controllerDirectory == resources.frontController.controllerDirectory APPLICATION_PATH "/controllers" APPLICATION_PATH "/controllers" [staging :: production] [staging production] [testing :: production] [testing production] phpSettings.display_startup_errors == 11 phpSettings.display_startup_errors phpSettings.display_errors == 11 phpSettings.display_errors [development :: production] [development production] phpSettings.display_startup_errors == 11 phpSettings.display_startup_errors phpSettings.display_errors == 11 phpSettings.display_errors
  • 18. .htaccess file SetEnv APPLICATION_ENV development SetEnv APPLICATION_ENV development RewriteEngine On RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] RewriteRule ^.*$ index.php [NC,L]
  • 19. Step 2:Create a controller
  • 20. Create a controllerAll controllers extend Zend_Controller_ActionNaming conventions  Controllers end with Controller: IndexController, GuestbookController  Action methods end with Action: signAction(), displayAction(), listAction() Controllers should be in the application/controllers/ directory, and named after the class, with a “.php” suffix: application/controllers/IndexController.php
  • 21. IndexController.php
  • 22. Step 3:Create the model
  • 23. Using the Model in the ControllerUsing the Model in the Controller• Controller needs to retrieve Model• To start, lets fetch listings
  • 24. Using the Model in the ControllerAdding the Model to the Controller
  • 25. Using the Model in the ControllerTable Module – Access Methods
  • 26. Step 4:Create views
  • 27. Create a view Create a view script• View scripts go in application/views/scripts/• View script resolution looks for a view script in a subdirectory named after the controller – Controller name used is same as it appears on the url: • “GuestbookController” appears on the URL as “guestbook”• View script name is the action name as it appears on the url:• “signAction()” appears on the URL as “sign”
  • 28. index/index.phtml view script
  • 29. Step 5:Create a form
  • 30. Create a FormZend_Form:• Flexible form generations• Element validation and filtering• Rendering View helper to render element Decorators for labels and HTML wrappers• Optional Zend_Config configuraion
  • 31. Create a form – Identify elementsGuestbook form:• Email address• Comment• Captcha to reduce spam entries• Submit button
  • 32. Create a form – Guestbook form
  • 33. Using the Form in the Controller• Controller needs to fetch form object• On landing page, display the form• On POST requests, attempt to validate the form• On successful submission, redirect
  • 34. Adding the form to the controller
  • 35. Step 6:Create a layout
  • 36. Layouts• We want our application views to appear in this:
  • 37. Thank you.