Zend Framework Workshop, DPC09

Embed Size (px)

Citation preview

Zend Framework Workshop

Matthew Weier O'PhinneyProject LeadZend Framework

Dutch PHP Conference11 April 2009Amsterdam

About me:ZF Contributor since January 2006

Assigned to the ZF team in July 2007

Promoted to Software Architect in April 2008

Project Lead since April 2009

Photo 2009, Chris Shiflett

What is
Zend Framework?

Full Stack Framework?

Component Library?

Both.

Today's Roadmap

Quick Start

Models

Service LayersAuthentication and Authorization

Zend_Form

Plugin Loading

Controllers

Views and Layouts

Service Endpoints

Quick Startor,
How I learned to use
and love Zend_Tool

In bin/zf.sh or 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

Or use pear.zfcampus.org PEAR channel

Locate the zf utility

Create the project

# Unix:% zf.sh create project quickstart

# DOS/Windows:C:> zf.bat create project quickstart

Add ZF to the project

# Symlink:% cd library; ln -s \ path/to/ZendFramework/library/Zend .

# Copy:% cd library; cp -r \ path/to/ZendFramework/library/Zend .

Create a vhost

ServerAdmin [email protected] DocumentRoot /abs/path/to/quickstart/public ServerName quickstart

DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all

Add a hosts entry

127.0.0.1 quickstart

Fire up your browser!

Looking under the hood

The
directory
tree

quickstart|-- application| |-- Bootstrap.php| |-- configs| | `-- application.ini| |-- controllers| | |-- ErrorController.php| | `-- IndexController.php| |-- models| `-- views| |-- helpers| `-- scripts| |-- error| | `-- error.phtml| `-- index| `-- index.phtml|-- library|-- public| `-- index.php`-- tests |-- application | `-- bootstrap.php |-- library | `-- bootstrap.php `-- phpunit.xml

14 directories, 10 files

The bootstrap

Note that it actually calls dispatch() on the action controller, which then attempts to call the appropriate action method.

$this->_helper->viewRenderer->setNoRender(true);

$this->_helper->layout->disableLayout();

Disabling views and layouts

Note that it actually calls dispatch() on the action controller, which then attempts to call the appropriate action method.

View scripts should be concise

Hint to the layout script from your view scripts (not your controllers!)

Layouts should use placeholders as much as possible

Setup common layout elements in a bootstrap resource

Recommendations

Note that it actually calls dispatch() on the action controller, which then attempts to call the appropriate action method.

Bootstrapping placeholders