Copyright © 2007, Zend Technologies Inc.
‘Zend Framework QuickStart’
Ed Kietlinski
Solutions Consultant
GETTING STARTED WITH ZEND FRAMEWORK for i5
Internet – Working Your I5 CANCELED
Zend Framework 1.5 Latest Features | 2
ZEND FRAMEWORK AGENDA
• I’m Not Larry Bolhuis and Yes PHP is very secure
• Some History - Why Zend Framework?
• Intro to MVC (Model-View-Controller) design pattern
• Let’s look at what it can do for you
• Web Services code!
• Major features & benefits for the new ZF 1.6 release
• Questions?
Zend Framework—In a nutshell
The leading open-source PHP framework has a flexible architecture that lets you easily build modern web applications
and web services
Zend Framework 1.5 Latest Features
| 4
ZEND FRAMEWORK ADVANTAGES
• Best Practices—As an exemplar ZF is best practice.
• Productive—reuse code quickly and often.
• Simple & Easy—just like PHP, ZF is easy to adopt.
• Extensible & Flexible—customize & add your value.
• High Quality—rigorously tested + built-in tests to use.
• Friendly License—new BSD = reuse code however you like; Apache-like CLA = safety for corporations.
• Modern—web services, syndication, AJAX, search, +
Zend Framework 1.5 Latest Features
Zend Framework 1.5 Latest Features | 5
PHP Ecosystem
| 6
ZEND FRAMEWORK FACTS
• 7 Million Downloads• 500+ registered contributors inc Large enterprises • 140,000 lines of PHP code• 87,000 words of documentation
translated into 5 major languages Over 520 code examples
• 60+ ZF based OpenSource based on SourceForge
Zend Framework 1.5 Latest Features
| 7
10 Things Every Developer Should Know about Zend Framework
1. Use-at-will architecture2. Enterprise level development framework3. Object Oriented, and not ashamed of it4. Web Services are first-class citizens5. It’s backed by Zend as well as Community6. Ajax is not an afterthought7. Only pure PHP implementation of Lucene8. A huge community that is just an email away9. Identity 2.010. Documentation up the wazoo ☺☺☺☺
And just in case you forget one of those. . .
• Hosting will not be a problem
Zend Framework 1.5 Latest Features
Zend Framework 1.5 Latest Features | 8
I5/OS Power Platform Specifics
• Zend Framework works the same
• Brings the world of MVC to the RPG community
• Can use with i5 Toolkit and 5250 API, etc.
• PDO for DB2 in beta (See 1.6 RC2) in 1.7
� can use PHP/i5 TOOLKIT instead to DB2
� PDO DB2 adapter preview version available.
• Use PACE Apache port 8000, .htacess critical to ZF
Zend Framework Contributor Process
| 10
ZEND FRAMEWORK – COMPONENTS
Zend Framework 1.5 Latest Features
ZF + i5 TOOLKIT + 5250 Bridge API
• SBS
+i5 Toolkit
5250 API
Copyright © 2007, Zend Technologies Inc.
Zend Framework Examples
Open Source http://magentocommerce.com
Others:
| 14
SELECTED ZEND FRAMEWORK USERS
Zend Framework 1.5 Latest Features
i5 Specific Example – Beverage Distributor
• #1 Wine and Spirits wholesaler in NJ
• Application – Web based customer care system.
• Problem – Originally a .NET app that was middleware between backend DB2 and frontEndWeb app.
� Issues with Syncing between FE and BE, data mismatches
� Finger pointing when problems, different owners at each layer
� Hard to extend and no onsite expertise
Copyright © 2007, Zend Technologies Inc.
MODEL-VIEW-CONTROLLER
DESIGN PATTERN
What is the MVC component?
• The heart of ZF web applications
� Best practice for application workflow
� Design pattern that dates back to
Smalltalk, circa 1979
• Model: data providerView: user interfaceController: request processor
• Simple solution in most applications
� Sensible defaults are built in
� Flexible and extensible
� Supports advanced applications
MODELVIEW
CONTROLLER
|16 apr 2008 | 18
M
Access/Business
Logic
C
Presentation
logic
RPG Model View Controller (MVC)
VIEW
V
RPG/Application
(Subroutine)
5250 Screen
(DDS)
RPG/Applicationflow
(Mainline)
|16 apr 2008 | 19
M
Access/Business
Logic
C
Presentation
logic
VIEW
V
Option 3: Zend 5250 Bridge
RPG/Application
Subroutine
RPG/Applicationflow
• Reuse Legacy application with new PHP GUI
5250 API request
XML
.
Populates Screen values with inputtedinformation using:<?phpset_include_path('/usr/local/Zend/5250/API/');require_once('Zend/5250.php');$bridge = new Zend_5250();$response = $bridge->connect();$bridge->setInputField('0','user');$bridge->setInputField('1','password');// press ENTER $response = $bridge->submit();$bridge->disconnect();?>
|16 apr 2008 | 20
M
Access/Business
Logic
C
Presentation
logic
VIEW
VBrowser web
Option 2: Restructure
• Develop new web services infrastructure
• Develop new GUI
RPG/Application
Subroutine
• Separate business logic from presentation
WEB 2.0 ?PHP + Toolkit
|16 apr 2008 | 21
M
Access/Business
Logic
C
Presentation
logic
VIEW
VBrowser web
NEW LIFE:PHP FUNCTION
Option 1: Rewrite
• Develop new presentation logic • Develop new GUI
• Develop new business logic
WEB 2.0 ?
PHP
|16 apr 2008 | 22
Options with Zend/PHP
• REWRITE
• Develop new GUI• Develop new presentation logic• Develop new business logic
• RESTRUCTURE• Separate business logic from presentation
logic• Develop new web services infrastructure
• REFACE w 5250 BRIDGE• Reuse legacy applications with new PHP
GUI from 5250 screen
.
Copyright © 2007, Zend Technologies Inc.
ZF= Developer Best Practices
4 ways ZF encourages best practices
1. Object-oriented programming
2. Testing3. Documentation
4. Extremely simple
• Most classes are reusable and extensible, allowing you to write less code
• User-defined extensions, plugins, and adapters implement interfaces and should be well-designed classes (i.e.Widgets)
• Uses many other design patterns
4 ways ZF encourages best practices
1. Object-oriented programming
2. Testing3. Documentation
4. Extremely simple
• MVC Request and Response can be simulated
• Built-in testability for Controllers
• Extensive collection of PHPUnit test suites serves as useful example
4 ways ZF encourages best practices
1. Object-oriented programming
2. Testing3. Documentation
4. Extremely simple
• Framework development process requires complete manual coverage for every component
• Framework coding standards include complete API docblocks to support reference documentation and development tools
• Examples and use cases a requirement for each component
4 ways ZF encourages best practices
1. Object-oriented programming
2. Testing3. Documentation
4. Extremely simple
• Simple interfaces are better for:
� Usability
� Extensibility
� Testability
� Maintainability
• Avoid “AntiPatterns”� Functional decomposition
� Spaghetti code
� http://www.antipatterns.com/
3 tools ZF offers to improve application security
1. Zend_Filter_Input2. Zend_Auth3. Zend_View
• Processes values of form fields
• Declares rules for filtering and validating input data
• Serves as a “cage” for data; only valid data come out
• Provides method for escaping values, to make them safer for HTML output
3 tools ZF offers to improve application security
1. Zend_Filter_Input2. Zend_Auth3. Zend_View
• Abstract interface to login credential storage
• Provides adapters for several directory solutions
� LDAP
� File
� Database table
� others
• Write your own custom directory adapters
*SBS
3 tools ZF offers to improve application security
1. Zend_Filter_Input2. Zend_Auth3. Zend_View
• Provides a method to format PHP objects more safely for HTML:
<?= $this->escape($this->var); ?>
*SBS
5 ways ZF helps to avoid reinventing the wheel
1. Zend_Acl2. Zend_Feed3. Zend_Log4. Zend_Cache5. Zend_Config
• Manages application roles, resources and privileges
• Roles and Resources may be user-defined classes
• Supports rule inheritance
• Supports conditional application of rules
5 ways ZF helps to avoid reinventing the wheel
1. Zend_Acl2. Zend_Feed3. Zend_Log4. Zend_Cache5. Zend_Config
• Consume RSS feed in a single line of PHP code
• Discover feed links automatically
• Imports feeds from multiple sources
• Provides feed building and posting operations
5 ways ZF helps to avoid reinventing the wheel
1. Zend_Acl2. Zend_Feed3. Zend_Log4. Zend_Cache5. Zend_Config
• Support advanced yet easy logging operations in your application
• Inspired by log4j
• Supports user-defined log formatting and writing
5 ways ZF helps to avoid reinventing the wheel
1. Zend_Acl2. Zend_Feed3. Zend_Log4. Zend_Cache5. Zend_Config
• Provides an interface to access persisted data
• Supports tagging, manipulating, iterating, and removing subsets
• Supports multiple cache storage backends(file, database, memcached, etc.)
*SBS
5 ways ZF helps to avoid reinventing the wheel
1. Zend_Acl2. Zend_Feed3. Zend_Log4. Zend_Cache5. Zend_Config
• Simplifies usage of configuration data for applications
• Provides a property-driven OO interface for accessing data hierarchy
• Supports multiple storage formats (.INI files, XML)
• Supports inheritance of configuration sections
• Optional; Zend Framework is configuration-less
A SOAP SERVER
• Zend_Soap_Server class is intended to simplify Web Services server part development.
• It’s OO wrapper around SOAP PHP extension SoapServer class which gives a flexible way to operate SOAP Server object.
• Two operational modes: WSDL and non-WSDL.
SOAP – Server example
SOAP - Client
• Zend_Soap_Client class is intended to simplify Web Services client part development.
• Two operational modes: WSDL and non-WSDL.
• Base for specific clients development (e.g. Zend_Soap_Client_DotNet is under development now).
SOAP Client - Example
Zend Framework Technology Partnerships | 40
CURRENT APIs & WEB SERVICES
“We have created a StrikeIron API in Zend Framework
because of its Web services consumption capabilities
and the momentum it is experiencing as a platform for
developing Web applications. This makes it extremely
easy for PHP developers to access multiple StrikeIron
services in a consistent way, greatly extending the
capabilities of Web apps that utilize Zend Framework.”
— Bob Brauer, CEO
StrikeIron
Web Services we
include as a part of
Zend Framework:
simpy del.icio.us
Our TechnologyPartners:
MVC
Int.Data
Web Services
BASE
Copyright © 2007, Zend Technologies Inc.
THE DEVELOPER’S FRAMEWORK
THINGS YOU SHOULD KNOW
New Features in 1.6
• Dojo 1.1.1 Framework integration in ZF
� JSON-RPC Server (a rewrite)
� Dojo.data Envelopes
� Dijit integration with Zend_Form & Zend_View
� Can custom build once project done to save bandwidth/space
• Better SOAP services (ie WSDL generator)
• Unit Test for Controllers (Zend_Test_PHPUnit_ControllerTestCase)
• Tooling Project (the CLI Tools)
• Paginator Component
• Zend_Session has new DB option
• Media View Helpers (Flash, QuickTime, Object, and Page)
Dojo Demo Example and Code online
Copyright © 2007, Zend Technologies Inc.
THE DEVELOPER’S FRAMEWORK
Tips on how to get Started
Zend Studio ZF Project will save lots of setup time
http://Framework.Zend.com
ZF+ZP for Development and Ops
Zend Framework Demos
• Demos� Feeds
� Gdata
• Blogger.php
• Calendar.php
• Gapps.php
• Gbase.php
• Spreadsheet� Mail
� Lucene Search
� WebServices
• Amazon
• Flickr
• UPC lookup
• Yahoo
Zend Framework Reference Guide (in PDF too)
Zend Framework 1.5 Latest Features | 50
ZEND FRAMEWORK BOOKS
Non-English
language books in
Japanese,
German,
Portuguese:
Zend Developer Zone on Zend.com
Zend Framework Support
Zend Framework Webinars
Zend Smart Start Program = Training + Mentoring
• Help customers rapidly adopt PHP for their application needs
• Get an Proof of Concept, that addresses a customer’s real business problem, up and running in 30 calendar days
• Bridge the learning gap between RPG and PHP
• Provide a foundation for leveraging PHP applications to address business objectives
SBS
Copyright © 2007, Zend Technologies Inc.
Q & A