SlideShare a Scribd company logo
Zend Framework
• What is Zend Framework?

• Getting and Installing Zend
  Framework

• MVC overview

• Quick Start to developing
  applications using Zend
  Framework's
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
What's in Zend Framework?
Requirments

•    PHP 5.1.4


•    Web server

•    Standard installation


•    Commonly no additional extensions needed
quickstart
             quickstart
The         |-- application
             |-- application
            || |-- Bootstrap.php
                 |-- Bootstrap.php
            || |-- configs
                 |-- configs
            || || `-- application.ini
directory            `-- application.ini
            || |-- controllers
                 |-- controllers
            || || |-- ErrorController.php
                     |-- ErrorController.php
            || || `-- IndexController.php
                     `-- IndexController.php
tree        || |-- 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
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"
Getting and
   Installing
Zend 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 GUI file manager
Add to your
include_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(),
 )));
  )));
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 your OS)
 Place bin/ in your path, or create an alias on
  your path:
  alias zf=/path/to/bin/zf.sh
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
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>
Fire up your browser!
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
.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]
Step 2:
Create a controller
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
IndexController.php
Step 3:
Create the model
Using the Model in the Controller
Using the Model in the Controller
•   Controller needs to retrieve Model
•   To start, let's fetch listings
Using the Model in the Controller
Adding the Model to the Controller
Using the Model in the Controller
Table Module – Access Methods
Step 4:
Create views
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”
index/index.phtml view script
Step 5:
Create a form
Create a Form

Zend_Form:

• Flexible form generations
• Element validation and filtering
• Rendering
      View helper to render element
    Decorators for labels and HTML wrappers
• Optional Zend_Config configuraion
Create a form – Identify elements
Guestbook 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 requests, attempt to validate the
  form
• On successful submission, redirect
Adding the form to the controller
Step 6:
Create a layout
Layouts
• We want our application views to appear in
  this:
Thank you.

More Related Content

PDF
Continuous Quality Assurance
PDF
What happens in laravel 4 bootstraping
PDF
Building web framework with Rack
PDF
Apache and PHP: Why httpd.conf is your new BFF!
PPTX
Reusable bootstrap resources zend con 2010
PDF
Building com Phing - 7Masters PHP
PDF
HTML5 tutorial: canvas, offfline & sockets
KEY
Using and scaling Rack and Rack-based middleware
Continuous Quality Assurance
What happens in laravel 4 bootstraping
Building web framework with Rack
Apache and PHP: Why httpd.conf is your new BFF!
Reusable bootstrap resources zend con 2010
Building com Phing - 7Masters PHP
HTML5 tutorial: canvas, offfline & sockets
Using and scaling Rack and Rack-based middleware

What's hot (20)

PDF
More tips n tricks
PDF
Application Layer in PHP
PDF
Ruby MVC from scratch with Rack
PDF
Automatisation in development and testing - within budget
PPTX
Laravel Beginners Tutorial 1
PPT
Build Automation of PHP Applications
PDF
Building and deploying PHP applications with Phing
PDF
Introduction to Flask Micro Framework
PPTX
Vagrant WordCamp Hamilton
PDF
Using Test Kitchen for testing Chef cookbooks
PDF
A reviravolta do desenvolvimento web
KEY
Composer
PDF
Ansible leveraging 2.0
PDF
Microservice Teststrategie mit Symfony2
KEY
PDF
PHP & Performance
PPTX
What mom never told you about bundle configurations - Symfony Live Paris 2012
 
PPTX
PHP 7 Crash Course - php[world] 2015
PDF
はじめてのSymfony2
PDF
Rails 4.0
More tips n tricks
Application Layer in PHP
Ruby MVC from scratch with Rack
Automatisation in development and testing - within budget
Laravel Beginners Tutorial 1
Build Automation of PHP Applications
Building and deploying PHP applications with Phing
Introduction to Flask Micro Framework
Vagrant WordCamp Hamilton
Using Test Kitchen for testing Chef cookbooks
A reviravolta do desenvolvimento web
Composer
Ansible leveraging 2.0
Microservice Teststrategie mit Symfony2
PHP & Performance
What mom never told you about bundle configurations - Symfony Live Paris 2012
 
PHP 7 Crash Course - php[world] 2015
はじめてのSymfony2
Rails 4.0
Ad

Similar to Zend Framework (20)

PDF
Building Web Applications with Zend Framework
ODP
CodeIgniter PHP MVC Framework
KEY
Improving QA on PHP projects - confoo 2011
PPT
Edp bootstrapping a-software_company
PDF
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
PDF
Quality Assurance for PHP projects - ZendCon 2012
KEY
Php Power Tools
PDF
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
PDF
「Code igniter」を読もう。〜ソースコードから知る仕様や拡張方法〜
PDF
Lean Php Presentation
KEY
Workshop quality assurance for php projects tek12
PDF
Puppet getting started by Dirk Götz
PDF
Workshop quality assurance for php projects - ZendCon 2013
PDF
BP-6 Repository Customization Best Practices
PDF
Filesystem Management with Flysystem at PHP UK 2023
KEY
PPTX
Introduction to Codeigniter
PDF
Test Kitchen and Infrastructure as Code
PDF
Workshop quality assurance for php projects - phpbelfast
PDF
Virtual Environment and Web development using Django
Building Web Applications with Zend Framework
CodeIgniter PHP MVC Framework
Improving QA on PHP projects - confoo 2011
Edp bootstrapping a-software_company
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Quality Assurance for PHP projects - ZendCon 2012
Php Power Tools
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
「Code igniter」を読もう。〜ソースコードから知る仕様や拡張方法〜
Lean Php Presentation
Workshop quality assurance for php projects tek12
Puppet getting started by Dirk Götz
Workshop quality assurance for php projects - ZendCon 2013
BP-6 Repository Customization Best Practices
Filesystem Management with Flysystem at PHP UK 2023
Introduction to Codeigniter
Test Kitchen and Infrastructure as Code
Workshop quality assurance for php projects - phpbelfast
Virtual Environment and Web development using Django
Ad

More from OpenSource Technologies Pvt. Ltd. (13)

PDF
OpenSource Technologies Portfolio
PPT
Cloud Computing Amazon
PPT
Empower your business with joomla
PPTX
Responsive Web Design Fundamentals
PPT
PHP Shield - The PHP Encoder
PPT
Introduction to Ubantu
PPT
PPT
WordPress Complete Tutorial
PPT
OpenSource Technologies Portfolio
Cloud Computing Amazon
Empower your business with joomla
Responsive Web Design Fundamentals
PHP Shield - The PHP Encoder
Introduction to Ubantu
WordPress Complete Tutorial

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Approach and Philosophy of On baking technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
DOCX
The AUB Centre for AI in Media Proposal.docx
PPT
Teaching material agriculture food technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Network Security Unit 5.pdf for BCA BBA.
Reach Out and Touch Someone: Haptics and Empathic Computing
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Programs and apps: productivity, graphics, security and other tools
sap open course for s4hana steps from ECC to s4
Spectral efficient network and resource selection model in 5G networks
Approach and Philosophy of On baking technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
cuic standard and advanced reporting.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
The AUB Centre for AI in Media Proposal.docx
Teaching material agriculture food technology

Zend Framework

  • 2. • What is Zend Framework? • Getting and Installing Zend Framework • MVC overview • Quick Start to developing applications using Zend Framework's
  • 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. What's in Zend Framework?
  • 5. Requirments • PHP 5.1.4 • Web server • Standard installation • Commonly no additional extensions needed
  • 6. quickstart quickstart The |-- application |-- application || |-- Bootstrap.php |-- Bootstrap.php || |-- configs |-- configs || || `-- application.ini directory `-- application.ini || |-- controllers |-- controllers || || |-- ErrorController.php |-- ErrorController.php || || `-- IndexController.php `-- IndexController.php tree || |-- 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 Installing Zend Framework
  • 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 your include_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(), ))); )));
  • 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
  • 23. Using the Model in the Controller Using the Model in the Controller • Controller needs to retrieve Model • To start, let's fetch listings
  • 24. Using the Model in the Controller Adding the Model to the Controller
  • 25. Using the Model in the Controller Table Module – Access Methods
  • 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”
  • 30. Create a Form Zend_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 elements Guestbook 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
  • 36. Layouts • We want our application views to appear in this: