SlideShare a Scribd company logo
1 of 24
Download to read offline
Head First Zend Framework
       Part 1 - Project & Application

                               Jace Ju
Install
   Get Zend Framework from svn repository.
# cd /path/to/library/php

# svn co http://framework.zend.com/svn/framework/standard/tags/release-
1.10.x/library/Zend

(add ZF_HOME = /path/to/ZF, example: /usr/local/ZF)

# cd $ZF_HOME

# svn co http://framework.zend.com/svn/framework/standard/tags/release-1.10.x/bin

# cd bin

# ln –s $ZF_HOME/bin/zf.sh $ZF_HOME/bin/zf
Setup
   Create config of zf script
# zf create config
Successfully written Zend Tool config.
It is located at: /usr/local/ZF/.zf.ini

(Bug in ZF 1.10.6.)
# vi /usr/local/ZF/.zf.ini
php.includepath change to php.include_path

# zf show config
User Configuration: /usr/local/ZF/.zf.ini
  `-- php
      `-- include_path: /usr/local/lib/php:/var/lib/php:.
What is zf script
   Help info
# zf ?
Usage:
    zf [--global-opts] action-name [--action-opts] provider-name [--provider-opts]
[provider parameters ...]
    Note: You may use "?" in any place of the above usage string to ask for more
specific help information.
    Example: "zf ? version" will list all available actions for the version provider.

... (ignore) ...

DbTable
    zf create db-table name actual-table-name module force-overwrite
    Note: There are specialties, use zf create db-table.? to get specific help on
them.

    ProjectProvider
      zf create project-provider name actions
Create Project
   Build a project skeleton
# cd /path/to/wwwroot

# zf create project zf_test
Creating project at /path/to/wwwroot/zf_test
Note: This command created a web project, for more information setting up your VHOST,
please see docs/README

# cd /path/to/wwwroot/zf_test

# zf show project.info
Working with project located at: /path/to/wwwroot/zf_test

# zf show profile
ProjectDirectory
    ProjectProfileFile
    ... (ignore) ...
    TestsDirectory
        TestPHPUnitConfigFile
        TestApplicationDirectory
            TestApplicationBootstrapFile
        TestLibraryDirectory
            TestLibraryBootstrapFile
Setup Project
   Setup VirtualHost in Apache config file
<VirtualHost *:80>
   DocumentRoot "/path/to/wwwroot/zf_test/public"
   ServerName zf_test

    # This should be omitted in the production environment
    SetEnv APPLICATION_ENV development

    <Directory "/path/to/wwwroot/zf_test/public">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>



   http://zf_test/
Create Protable Project
   Change position of index.php and .htaccess
# cd /path/to/wwwroot/zf_test

# cp public/.htaccess .

# cp public/index.php .

# vi public/.htaccess
RewriteEngine Off

# vi public/index.php
<?php
header('HTTP/1.1 403 Forbidden');

# vi .htaccess
SetEnv APPLICATION_ENV development

# vi index.php
'/../application' change to '/application'



   http://localhost/zf_test/
Project Structure
   application
       configs
       controllers
       models
       views
           helpers
           scripts
   docs
   library
   public
   tests
Application
   Zend_Application
   Zend_Application_Bootstrap
   Zend_Application_Resource
Zend_Application
   Load Configuration.
   Initialize bootstrap.
   Run.
# cd /path/to/wwwroot/zf_test

# vi index.php
... (ignore) ...

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();
application.ini
   Configuration section.
# cd /path/to/wwwroot/zf_test

# vi application/configs/application.ini
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
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
resources.frontController.params.displayExceptions = 1
phpSettings in application.ini
   Use "ini_set" function.
   See http://www.php.net/manual/en/ini.list.php.
includePaths in application.ini
   Use "set_include_path" function.
   Prepend to "include_path".
   "library" is identity for configuration.
bootstrap in application.ini
   To load Bootstrap class.
Zend_Application_Bootstrap
   Initialize custom resources for project.
# cd /path/to/wwwroot/zf_test

# vi application/Bootstrap.php
<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initResource1()
    {
        $this->bootstrap('resource2'); // Initialize Resource 2 first.
        echo "Initialize Resource 1n";
    }

     protected function _initResource2()
     {
         echo "Initialize Resource 2n ";
     }
}
appnamespace in application.ini
   Define the autoloader prefix of models, form,
    etc.
resources in application.ini
   Load common resources.
   Define resource options.
FrontController Resource
   Initialize Front Controller.
   frontController.controllerdirectory
       call Zend_Controller_Front::setControllerDirectory()
   frontController.params
       call Zend_Controller_Front::setParams()
Zend_Application_Resource
   Common Resources
       Front Controller
       Router
       Database
       View
       Session
       Layout
       Log
       ...
   More flexible then Bootstrap::_init<Resource>
    method.
Example: Database Resource
   Initialize Custom Resources for Project
# cd /path/to/wwwroot/zf_test

# zf configure db-adapter "adapter=mysqli&username=uname&password=mypass&dbname=mydb"
A db configuration for the production section has been written to the application
config file.

# vi application/configs/application.ini
[production]
... (ignore) ...
resources.db.adapter = "mysqli"
resources.db.params.username = "uname"
resources.db.params.password = "mypass"
resources.db.params.dbname = "mydb"

... (ignore) ...




   Will initialize Zend_Application_Resource_Db
Autoloadernamespaces in application.ini
   Register the prefix of library.
Autoloadernamespaces[] = "My_"
pluginPaths in application.ini
   Register the prefix and path of plugin classes.
   Resolve loading order of plugin.
pluginPaths.My_Application_Resource_ = "My/Application/Resource"
Summary
   Zend_Application
       Load configuration.
       Set bootstrap and run.
   Zend_Application_Bootstrap
       Initialize resources.
   Zend_Application_Resource
       Get options from configuration.
       Initialize controller, view, database, etc.
See you next part.

More Related Content

What's hot

Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Caldera Labs
 
Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
 Connecting Content Silos: One CMS, Many Sites With The WordPress REST API Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
Connecting Content Silos: One CMS, Many Sites With The WordPress REST APICaldera Labs
 
Using the new WordPress REST API
Using the new WordPress REST APIUsing the new WordPress REST API
Using the new WordPress REST APICaldera Labs
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersCaldera Labs
 
Codeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework ComponentsCodeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework ComponentsAbdul Malik Ikhsan
 
Reusable bootstrap resources zend con 2010
Reusable bootstrap resources   zend con 2010Reusable bootstrap resources   zend con 2010
Reusable bootstrap resources zend con 2010Hector Virgen
 
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCaldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCalderaLearn
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkMichael Peacock
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswanivvaswani
 
Zend Framework 2 - presentation
Zend Framework 2 - presentationZend Framework 2 - presentation
Zend Framework 2 - presentationyamcsha
 
ACL in CodeIgniter
ACL in CodeIgniterACL in CodeIgniter
ACL in CodeIgnitermirahman
 
ZF2 for the ZF1 Developer
ZF2 for the ZF1 DeveloperZF2 for the ZF1 Developer
ZF2 for the ZF1 DeveloperGary Hockin
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)andrewnacin
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindValentine Matsveiko
 

What's hot (20)

Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
 
Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
 Connecting Content Silos: One CMS, Many Sites With The WordPress REST API Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
 
Using the new WordPress REST API
Using the new WordPress REST APIUsing the new WordPress REST API
Using the new WordPress REST API
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
 
Codeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework ComponentsCodeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework Components
 
CodeIgniter 3.0
CodeIgniter 3.0CodeIgniter 3.0
CodeIgniter 3.0
 
Reusable bootstrap resources zend con 2010
Reusable bootstrap resources   zend con 2010Reusable bootstrap resources   zend con 2010
Reusable bootstrap resources zend con 2010
 
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCaldera Learn - LoopConf WP API + Angular FTW Workshop
Caldera Learn - LoopConf WP API + Angular FTW Workshop
 
Phinx talk
Phinx talkPhinx talk
Phinx talk
 
Kyiv.py #17 Flask talk
Kyiv.py #17 Flask talkKyiv.py #17 Flask talk
Kyiv.py #17 Flask talk
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 
Zend Framework 2 - presentation
Zend Framework 2 - presentationZend Framework 2 - presentation
Zend Framework 2 - presentation
 
ACL in CodeIgniter
ACL in CodeIgniterACL in CodeIgniter
ACL in CodeIgniter
 
ZF2 for the ZF1 Developer
ZF2 for the ZF1 DeveloperZF2 for the ZF1 Developer
ZF2 for the ZF1 Developer
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
 
Complex Sites with Silex
Complex Sites with SilexComplex Sites with Silex
Complex Sites with Silex
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mind
 

Similar to Head First Zend Framework - Part 1 Project & Application

Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolGordon Forsythe
 
Getting up & running with zend framework
Getting up & running with zend frameworkGetting up & running with zend framework
Getting up & running with zend frameworkSaidur Rahman
 
Introduction to Zend framework
Introduction to Zend framework Introduction to Zend framework
Introduction to Zend framework Matteo Magni
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Deepak Garg
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment TacticsIan Barber
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"? Fabien Doiron
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011Michelangelo van Dam
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code baseRobert Munteanu
 
Scaling up development of a modular code base - R Munteanu
Scaling up development of a modular code base - R MunteanuScaling up development of a modular code base - R Munteanu
Scaling up development of a modular code base - R Munteanumfrancis
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend FrameworkAdam Culp
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppSmartLogic
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)Paul Jones
 

Similar to Head First Zend Framework - Part 1 Project & Application (20)

Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
Getting up & running with zend framework
Getting up & running with zend frameworkGetting up & running with zend framework
Getting up & running with zend framework
 
Getting up and running with Zend Framework
Getting up and running with Zend FrameworkGetting up and running with Zend Framework
Getting up and running with Zend Framework
 
Introduction to Zend framework
Introduction to Zend framework Introduction to Zend framework
Introduction to Zend framework
 
Write php deploy everywhere
Write php deploy everywhereWrite php deploy everywhere
Write php deploy everywhere
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
 
Bangpypers april-meetup-2012
Bangpypers april-meetup-2012Bangpypers april-meetup-2012
Bangpypers april-meetup-2012
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment Tactics
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"?
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code base
 
Scaling up development of a modular code base - R Munteanu
Scaling up development of a modular code base - R MunteanuScaling up development of a modular code base - R Munteanu
Scaling up development of a modular code base - R Munteanu
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend Framework
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
Maven
MavenMaven
Maven
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)
 

More from Jace Ju

Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in actionJace Ju
 
Beginning PHPUnit
Beginning PHPUnitBeginning PHPUnit
Beginning PHPUnitJace Ju
 
深入淺出 MVC
深入淺出 MVC深入淺出 MVC
深入淺出 MVCJace Ju
 
如何打造 WebMVC Framework - 基礎概念篇
如何打造 WebMVC Framework - 基礎概念篇如何打造 WebMVC Framework - 基礎概念篇
如何打造 WebMVC Framework - 基礎概念篇Jace Ju
 
Refactoring with Patterns in PHP
Refactoring with Patterns in PHPRefactoring with Patterns in PHP
Refactoring with Patterns in PHPJace Ju
 
Patterns in Library Design (套件設計裡的模式)
Patterns in Library Design (套件設計裡的模式)Patterns in Library Design (套件設計裡的模式)
Patterns in Library Design (套件設計裡的模式)Jace Ju
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介Jace Ju
 
Patterns in Zend Framework
Patterns in Zend FrameworkPatterns in Zend Framework
Patterns in Zend FrameworkJace Ju
 
常見設計模式介紹
常見設計模式介紹常見設計模式介紹
常見設計模式介紹Jace Ju
 
PHPUnit 入門介紹
PHPUnit 入門介紹PHPUnit 入門介紹
PHPUnit 入門介紹Jace Ju
 
Web Refactoring
Web RefactoringWeb Refactoring
Web RefactoringJace Ju
 
jQuery 實戰經驗講座
jQuery 實戰經驗講座jQuery 實戰經驗講座
jQuery 實戰經驗講座Jace Ju
 
CSS 排版 - 基礎觀念篇
CSS 排版 - 基礎觀念篇CSS 排版 - 基礎觀念篇
CSS 排版 - 基礎觀念篇Jace Ju
 
PHP 防駭 - 基礎觀念篇
PHP 防駭 - 基礎觀念篇PHP 防駭 - 基礎觀念篇
PHP 防駭 - 基礎觀念篇Jace Ju
 
PHP 物件導向 - 基礎觀念篇
PHP 物件導向 - 基礎觀念篇PHP 物件導向 - 基礎觀念篇
PHP 物件導向 - 基礎觀念篇Jace Ju
 

More from Jace Ju (15)

Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
 
Beginning PHPUnit
Beginning PHPUnitBeginning PHPUnit
Beginning PHPUnit
 
深入淺出 MVC
深入淺出 MVC深入淺出 MVC
深入淺出 MVC
 
如何打造 WebMVC Framework - 基礎概念篇
如何打造 WebMVC Framework - 基礎概念篇如何打造 WebMVC Framework - 基礎概念篇
如何打造 WebMVC Framework - 基礎概念篇
 
Refactoring with Patterns in PHP
Refactoring with Patterns in PHPRefactoring with Patterns in PHP
Refactoring with Patterns in PHP
 
Patterns in Library Design (套件設計裡的模式)
Patterns in Library Design (套件設計裡的模式)Patterns in Library Design (套件設計裡的模式)
Patterns in Library Design (套件設計裡的模式)
 
購物車程式架構簡介
購物車程式架構簡介購物車程式架構簡介
購物車程式架構簡介
 
Patterns in Zend Framework
Patterns in Zend FrameworkPatterns in Zend Framework
Patterns in Zend Framework
 
常見設計模式介紹
常見設計模式介紹常見設計模式介紹
常見設計模式介紹
 
PHPUnit 入門介紹
PHPUnit 入門介紹PHPUnit 入門介紹
PHPUnit 入門介紹
 
Web Refactoring
Web RefactoringWeb Refactoring
Web Refactoring
 
jQuery 實戰經驗講座
jQuery 實戰經驗講座jQuery 實戰經驗講座
jQuery 實戰經驗講座
 
CSS 排版 - 基礎觀念篇
CSS 排版 - 基礎觀念篇CSS 排版 - 基礎觀念篇
CSS 排版 - 基礎觀念篇
 
PHP 防駭 - 基礎觀念篇
PHP 防駭 - 基礎觀念篇PHP 防駭 - 基礎觀念篇
PHP 防駭 - 基礎觀念篇
 
PHP 物件導向 - 基礎觀念篇
PHP 物件導向 - 基礎觀念篇PHP 物件導向 - 基礎觀念篇
PHP 物件導向 - 基礎觀念篇
 

Recently uploaded

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesExploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesSanjay Willie
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Fact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMsFact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMsZilliz
 

Recently uploaded (20)

Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesExploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Fact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMsFact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMs
 

Head First Zend Framework - Part 1 Project & Application

  • 1. Head First Zend Framework Part 1 - Project & Application Jace Ju
  • 2. Install  Get Zend Framework from svn repository. # cd /path/to/library/php # svn co http://framework.zend.com/svn/framework/standard/tags/release- 1.10.x/library/Zend (add ZF_HOME = /path/to/ZF, example: /usr/local/ZF) # cd $ZF_HOME # svn co http://framework.zend.com/svn/framework/standard/tags/release-1.10.x/bin # cd bin # ln –s $ZF_HOME/bin/zf.sh $ZF_HOME/bin/zf
  • 3. Setup  Create config of zf script # zf create config Successfully written Zend Tool config. It is located at: /usr/local/ZF/.zf.ini (Bug in ZF 1.10.6.) # vi /usr/local/ZF/.zf.ini php.includepath change to php.include_path # zf show config User Configuration: /usr/local/ZF/.zf.ini `-- php `-- include_path: /usr/local/lib/php:/var/lib/php:.
  • 4. What is zf script  Help info # zf ? Usage: zf [--global-opts] action-name [--action-opts] provider-name [--provider-opts] [provider parameters ...] Note: You may use "?" in any place of the above usage string to ask for more specific help information. Example: "zf ? version" will list all available actions for the version provider. ... (ignore) ... DbTable zf create db-table name actual-table-name module force-overwrite Note: There are specialties, use zf create db-table.? to get specific help on them. ProjectProvider zf create project-provider name actions
  • 5. Create Project  Build a project skeleton # cd /path/to/wwwroot # zf create project zf_test Creating project at /path/to/wwwroot/zf_test Note: This command created a web project, for more information setting up your VHOST, please see docs/README # cd /path/to/wwwroot/zf_test # zf show project.info Working with project located at: /path/to/wwwroot/zf_test # zf show profile ProjectDirectory ProjectProfileFile ... (ignore) ... TestsDirectory TestPHPUnitConfigFile TestApplicationDirectory TestApplicationBootstrapFile TestLibraryDirectory TestLibraryBootstrapFile
  • 6. Setup Project  Setup VirtualHost in Apache config file <VirtualHost *:80> DocumentRoot "/path/to/wwwroot/zf_test/public" ServerName zf_test # This should be omitted in the production environment SetEnv APPLICATION_ENV development <Directory "/path/to/wwwroot/zf_test/public"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>  http://zf_test/
  • 7. Create Protable Project  Change position of index.php and .htaccess # cd /path/to/wwwroot/zf_test # cp public/.htaccess . # cp public/index.php . # vi public/.htaccess RewriteEngine Off # vi public/index.php <?php header('HTTP/1.1 403 Forbidden'); # vi .htaccess SetEnv APPLICATION_ENV development # vi index.php '/../application' change to '/application'  http://localhost/zf_test/
  • 8. Project Structure  application  configs  controllers  models  views  helpers  scripts  docs  library  public  tests
  • 9. Application  Zend_Application  Zend_Application_Bootstrap  Zend_Application_Resource
  • 10. Zend_Application  Load Configuration.  Initialize bootstrap.  Run. # cd /path/to/wwwroot/zf_test # vi index.php ... (ignore) ... // Create application, bootstrap, and run $application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $application->bootstrap() ->run();
  • 11. application.ini  Configuration section. # cd /path/to/wwwroot/zf_test # vi application/configs/application.ini [production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 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 resources.frontController.params.displayExceptions = 1
  • 12. phpSettings in application.ini  Use "ini_set" function.  See http://www.php.net/manual/en/ini.list.php.
  • 13. includePaths in application.ini  Use "set_include_path" function.  Prepend to "include_path".  "library" is identity for configuration.
  • 14. bootstrap in application.ini  To load Bootstrap class.
  • 15. Zend_Application_Bootstrap  Initialize custom resources for project. # cd /path/to/wwwroot/zf_test # vi application/Bootstrap.php <?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initResource1() { $this->bootstrap('resource2'); // Initialize Resource 2 first. echo "Initialize Resource 1n"; } protected function _initResource2() { echo "Initialize Resource 2n "; } }
  • 16. appnamespace in application.ini  Define the autoloader prefix of models, form, etc.
  • 17. resources in application.ini  Load common resources.  Define resource options.
  • 18. FrontController Resource  Initialize Front Controller.  frontController.controllerdirectory  call Zend_Controller_Front::setControllerDirectory()  frontController.params  call Zend_Controller_Front::setParams()
  • 19. Zend_Application_Resource  Common Resources  Front Controller  Router  Database  View  Session  Layout  Log  ...  More flexible then Bootstrap::_init<Resource> method.
  • 20. Example: Database Resource  Initialize Custom Resources for Project # cd /path/to/wwwroot/zf_test # zf configure db-adapter "adapter=mysqli&username=uname&password=mypass&dbname=mydb" A db configuration for the production section has been written to the application config file. # vi application/configs/application.ini [production] ... (ignore) ... resources.db.adapter = "mysqli" resources.db.params.username = "uname" resources.db.params.password = "mypass" resources.db.params.dbname = "mydb" ... (ignore) ...  Will initialize Zend_Application_Resource_Db
  • 21. Autoloadernamespaces in application.ini  Register the prefix of library. Autoloadernamespaces[] = "My_"
  • 22. pluginPaths in application.ini  Register the prefix and path of plugin classes.  Resolve loading order of plugin. pluginPaths.My_Application_Resource_ = "My/Application/Resource"
  • 23. Summary  Zend_Application  Load configuration.  Set bootstrap and run.  Zend_Application_Bootstrap  Initialize resources.  Zend_Application_Resource  Get options from configuration.  Initialize controller, view, database, etc.
  • 24. See you next part.