Zend Framework
• What is Zend Framework?• Getting and Installing Zend  Framework• MVC overview• Quick Start to developing  applications u...
What is Zend Framework?•    PHP 5 library for web development     productivity•    Free, Open source•    Class library – f...
Whats in Zend Framework?
Requirments•    PHP 5.1.4•    Web server•    Standard installation•    Commonly no additional extensions needed
quickstart             quickstartThe         |-- application             |-- application            || |-- Bootstrap.php  ...
Sample INI config[production] [production]app.name = "Foo!" app.name = "Foo!"db.adapter = "Pdo_Mysql" db.adapter = "Pdo_My...
Getting and   InstallingZend Framework
Always found at:http://framework.zend.com     /download/latest
Unzip/Untar• Use CLI:  % tar xzf ZendFramework-1.9.2-  minimal.tar.gz  % unzip ZendFramework-1.9.2-  minimal.zip• Or use a...
Add to yourinclude_path <?php  <?php set_include_path(implode(PATH_SEPARATOR, array(  set_include_path(implode(PATH_SEPARA...
Step 1:Create the project
Locate the zfModel in the Controller  Using the utility In bin/zf.sh of bin/zf.bat of your ZF install  (choose based on y...
Create the project    # Unix:     # Unix:    % zf.sh create project quickstart     % zf.sh create project quickstart    # ...
Create a vhost<VirtualHost *:80> <VirtualHost *:80>    ServerAdmin you@atyour.tld     ServerAdmin you@atyour.tld    Docume...
Fire up your browser!
Configuration [production]  [production] phpSettings.display_startup_errors == 00  phpSettings.display_startup_errors phpS...
.htaccess file   SetEnv APPLICATION_ENV development    SetEnv APPLICATION_ENV development   RewriteEngine On    RewriteEng...
Step 2:Create a controller
Create a controllerAll controllers extend Zend_Controller_ActionNaming conventions   Controllers end with Controller:  ...
IndexController.php
Step 3:Create the model
Using the Model in the ControllerUsing the Model in the Controller•   Controller needs to retrieve Model•   To start, lets...
Using the Model in the ControllerAdding the Model to the Controller
Using the Model in the ControllerTable Module – Access Methods
Step 4:Create views
Create a view         Create a view script•    View scripts go in application/views/scripts/•    View script resolution lo...
index/index.phtml view script
Step 5:Create a form
Create a FormZend_Form:• Flexible form generations• Element validation and filtering• Rendering      View helper to render...
Create a form – Identify elementsGuestbook form:• Email address• Comment• Captcha to reduce spam entries• Submit button
Create a form – Guestbook form
Using the Form in the Controller• Controller needs to fetch form object• On landing page, display the form• On POST reques...
Adding the form to the controller
Step 6:Create a layout
Layouts• We want our application views to appear in  this:
Thank you.
Upcoming SlideShare
Loading in...5
×

Zend Framework

12,726

Published on

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

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

No Downloads
Views
Total Views
12,726
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
28
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Zend Framework

  1. 1. Zend Framework
  2. 2. • What is Zend Framework?• Getting and Installing Zend Framework• MVC overview• Quick Start to developing applications using Zend Frameworks
  3. 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. 4. Whats in Zend Framework?
  5. 5. Requirments• PHP 5.1.4• Web server• Standard installation• Commonly no additional extensions needed
  6. 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. 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. 8. Getting and InstallingZend Framework
  9. 9. Always found at:http://framework.zend.com /download/latest
  10. 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. 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. 12. Step 1:Create the project
  13. 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. 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. 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. 16. Fire up your browser!
  17. 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. 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. 19. Step 2:Create a controller
  20. 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. 21. IndexController.php
  22. 22. Step 3:Create the model
  23. 23. Using the Model in the ControllerUsing the Model in the Controller• Controller needs to retrieve Model• To start, lets fetch listings
  24. 24. Using the Model in the ControllerAdding the Model to the Controller
  25. 25. Using the Model in the ControllerTable Module – Access Methods
  26. 26. Step 4:Create views
  27. 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. 28. index/index.phtml view script
  29. 29. Step 5:Create a form
  30. 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. 31. Create a form – Identify elementsGuestbook form:• Email address• Comment• Captcha to reduce spam entries• Submit button
  32. 32. Create a form – Guestbook form
  33. 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. 34. Adding the form to the controller
  35. 35. Step 6:Create a layout
  36. 36. Layouts• We want our application views to appear in this:
  37. 37. Thank you.
  1. A particular slide catching your eye?

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

×