What's New in ZF 1.10

Preview:

DESCRIPTION

Slides from a webinar where we discussed the new features in Zend Framework 1.10

Citation preview

© All rights reserved. Zend Technologies, Inc.

What's New in ZF 1.10?Ralph SchindlerZend Framework Software Engineer

© All rights reserved. Zend Technologies, Inc.

In a Nutshell Numerous improvements New Components New Services Documentation updates

© All rights reserved. Zend Technologies, Inc.3

Improvements

Building incrementally

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Filter_Boolean

4 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Filter_Null

5 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Filter_Compress / Decompress

6 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Validate_Callback

7 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Validate_CreditCardSupported CC Institutes:

• American Express, China UnionPay

• Diners Club Card Blanche, Diners Club International, Diners Club US & Canada

• Discover Card, JCB, Laser, Maestro

• MasterCard, Solo

• Visa, Visa Electron

8 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Validate_PostCodeAllows you to determine if a given value is a

valid postal code

Locale aware

9 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Log::factory() & Zend Monitor Writer Adapter

10 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Log::factory() & Zend Monitor Writer Adapter

11 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Pdf performance enhancements

•Zend_Exception previous Exception support

•Zend_Loader::loadClass() PSR-0 recommendations

•Upgrade to Dojo 1.4

12 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Application ResourcesCachemanager

Dojo

Jquery

Layout

Log

Mail

Multidb

13 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

•Zend_Tool ProvidersNo more IncludePath scanner – Explicit loader

Home directory & Configuration

DbAdapter Provider

Layout Provider

Basic Scaffolding• Model Provider

• Form Provider

Project in 1.10+ generated with Application_ prefix in code & bootstrap support

14 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

Improvements

© All rights reserved. Zend Technologies, Inc.

Improvements

© All rights reserved. Zend Technologies, Inc.

Improvements

© All rights reserved. Zend Technologies, Inc.18

New Components

Extending an already extensible and extensive framework

© All rights reserved. Zend Technologies, Inc.

Zend_Barcode Create barcodes, and render as PDF or

images Validate barcode values

© All rights reserved. Zend Technologies, Inc.20

$renderer = Zend_Barcode::factory( 'code39', // barcode type 'image', // image or PDF array( // barcode options 'text' => 'ZENDFRAMEWORK', ), array( // renderer options 'imageType' => 'png', ));$image = $renderer->draw();imagepng($image, __DIR__ . '/barcode.png');

$renderer = Zend_Barcode::factory( 'code39', // barcode type 'image', // image or PDF array( // barcode options 'text' => 'ZENDFRAMEWORK', ), array( // renderer options 'imageType' => 'png', ));$image = $renderer->draw();imagepng($image, __DIR__ . '/barcode.png');

© All rights reserved. Zend Technologies, Inc.21

$validator = new Zend_Validate_Barcode('CODE39');if ($validator->isValid($input)) { // valid barcode text} else { // invalid barcode text}

$validator = new Zend_Validate_Barcode('CODE39');if ($validator->isValid($input)) { // valid barcode text} else { // invalid barcode text}

© All rights reserved. Zend Technologies, Inc.

Zend_Cache New backend: Zend_Cache_Backend_Static

Cache to named files in your document root Skip PHP altogether for cached content!

New: Zend_Cache_Manager Use configuration to create Cache objects Acts as both a factory and repository for

multiple Cache objects Aids usage of multi-tiered caching strategies

in your ZF applications

© All rights reserved. Zend Technologies, Inc.23

RewriteCond %{DOCUMENT_ROOT}/cached/% {REQUEST_URI}.html -fRewriteRule .* cached/%{REQUEST_URI}.%1 [L]

RewriteCond %{DOCUMENT_ROOT}/cached/% {REQUEST_URI}.html -fRewriteRule .* cached/%{REQUEST_URI}.%1 [L]

© All rights reserved. Zend Technologies, Inc.24

$options = array( 'public_dir' => APPLICATION_PATH . '/../public/cache',);// Where $manager is a Zend_Cache_Manager instance$manager->setTemplateOptions('page', $options);$cache = $manager->getCache('page');

// In an action controller:public function preDispatch(){ $this->_helper->cache( // cache these actions: array('foo', 'bar', 'baz'), // use these tags: array($this->_request->getControllerName()), // with this extension: 'html' );}

$options = array( 'public_dir' => APPLICATION_PATH . '/../public/cache',);// Where $manager is a Zend_Cache_Manager instance$manager->setTemplateOptions('page', $options);$cache = $manager->getCache('page');

// In an action controller:public function preDispatch(){ $this->_helper->cache( // cache these actions: array('foo', 'bar', 'baz'), // use these tags: array($this->_request->getControllerName()), // with this extension: 'html' );}

© All rights reserved. Zend Technologies, Inc.25

$manager = new Zend_Cache_Manager;$dbCache = array( 'frontend' => array( 'name' => 'Core', 'options' => array( 'lifetime' => 3600, 'automatic_serialization' => true, ) ), 'backend' => array( 'name' => 'Core', 'options' => array( 'cache_dir' => APPLICATION_PATH . '/../data/cache/db', ), ),);$manager->setCacheTemplate('db', $dbCache);$cache = $manager->getCache('db');

$manager = new Zend_Cache_Manager;$dbCache = array( 'frontend' => array( 'name' => 'Core', 'options' => array( 'lifetime' => 3600, 'automatic_serialization' => true, ) ), 'backend' => array( 'name' => 'Core', 'options' => array( 'cache_dir' => APPLICATION_PATH . '/../data/cache/db', ), ),);$manager->setCacheTemplate('db', $dbCache);$cache = $manager->getCache('db');

© All rights reserved. Zend Technologies, Inc.

Zend_Feed_Writer Sibling to Zend_Feed_Reader, introduced

in ZF 1.9.0 Provides full capabilities for generation of

a variety of feeds, including feed extensions

RSS RSS2 Atom DublinCore etc.

© All rights reserved. Zend Technologies, Inc.27

$feed = new Zend_Feed_Writer_Feed;$feed->setTitle('ZF Webinars') ->setLink( 'http://framework.zend.com/webinars/atom', 'atom') ->addAuthor(array( 'name' => 'ZF DevTeam', 'email' => 'fw-general@lists.zend.com', 'uri' => 'http://framework.zend.com/', )) ->setDateModified(strtotime( '2010-03-17 12:00:00'));

$feed = new Zend_Feed_Writer_Feed;$feed->setTitle('ZF Webinars') ->setLink( 'http://framework.zend.com/webinars/atom', 'atom') ->addAuthor(array( 'name' => 'ZF DevTeam', 'email' => 'fw-general@lists.zend.com', 'uri' => 'http://framework.zend.com/', )) ->setDateModified(strtotime( '2010-03-17 12:00:00'));

© All rights reserved. Zend Technologies, Inc.28

$entry = $feed->createEntry();$entry->setLink( 'http://framework.zend.com/webinars/2010-03-17') ->addAuthor(array( 'name' => 'Ralph Schindler', 'email' => 'ralph.schindler@zend.com', 'uri' => 'http://framework.zend.com/', )) ->setDateModified(strtotime( '2010-03-17 12:00:00')) ->setDateCreated(strtotime( '2010-03-15 08:39:00'));

$output = $feed->export('atom');

$entry = $feed->createEntry();$entry->setLink( 'http://framework.zend.com/webinars/2010-03-17') ->addAuthor(array( 'name' => 'Ralph Schindler', 'email' => 'ralph.schindler@zend.com', 'uri' => 'http://framework.zend.com/', )) ->setDateModified(strtotime( '2010-03-17 12:00:00')) ->setDateCreated(strtotime( '2010-03-15 08:39:00'));

$output = $feed->export('atom');

© All rights reserved. Zend Technologies, Inc.

Zend_Feed_Pubsubhubbub Act as either a PuSH subscriber or

publisher Subscriber functionality allows

specifying a callback URL for PuSH's “fat pings”

Uses DB storage by default to track what feeds have been received previously

Publisher allows pinging a hub to notify that new content is available

© All rights reserved. Zend Technologies, Inc.30

$publisher = new Zend_Feed_Pubsubhubbub_Publisher;$publisher->addHubUrls(array( 'http://pubsubhubbub.appspot.com/', 'http://wordpress.org/extend/plugins/pushpress/', )) ->addUpdatedTopicUrls(array( 'http://framework.zend.com/webinars/atom', ));// Notify$publisher->notifyAll();

$publisher = new Zend_Feed_Pubsubhubbub_Publisher;$publisher->addHubUrls(array( 'http://pubsubhubbub.appspot.com/', 'http://wordpress.org/extend/plugins/pushpress/', )) ->addUpdatedTopicUrls(array( 'http://framework.zend.com/webinars/atom', ));// Notify$publisher->notifyAll();

© All rights reserved. Zend Technologies, Inc.31

$storage = new Zend_Feed_Pubsubhubbub_Model_Subscription;

$subscriber = new Zend_Feed_Pubsubhubbub_Subscriber;$subscriber->setStorage($storage) ->addHubUrl( 'http://pubsubhubbub.appspot.com/') ->setTopicUrl( 'http://framework.zend.com/webinars/atom') ->setCallbackUrl( 'http://www.mydomain.com/hubbub/callback') ->subscribeAll();

$storage = new Zend_Feed_Pubsubhubbub_Model_Subscription;

$subscriber = new Zend_Feed_Pubsubhubbub_Subscriber;$subscriber->setStorage($storage) ->addHubUrl( 'http://pubsubhubbub.appspot.com/') ->setTopicUrl( 'http://framework.zend.com/webinars/atom') ->setCallbackUrl( 'http://www.mydomain.com/hubbub/callback') ->subscribeAll();

© All rights reserved. Zend Technologies, Inc.32

$callback = new Zend_Feed_Pubsubhubbub_Subscriber_Callback;$callback->setStorage($storage);$callback->handle();$callback->sendResponse();

if ($callback->hasFeedUpdate()) { $feedString = $callback->getFedUpdate(); // start processing!}

$callback = new Zend_Feed_Pubsubhubbub_Subscriber_Callback;$callback->setStorage($storage);$callback->handle();$callback->sendResponse();

if ($callback->hasFeedUpdate()) { $feedString = $callback->getFedUpdate(); // start processing!}

© All rights reserved. Zend Technologies, Inc.

Zend_Markup Parser and renderer functionality Supports:

BBCode Textile

$bbcode = Zend_Markup::factory('Bbcode');echo $bbcode->render($someBbCodeMarkup);

$textile = Zend_Markup::factory('Textile');echo $textile->render($someTextileMarkup);

$bbcode = Zend_Markup::factory('Bbcode');echo $bbcode->render($someBbCodeMarkup);

$textile = Zend_Markup::factory('Textile');echo $textile->render($someTextileMarkup);

© All rights reserved. Zend Technologies, Inc.

Zend_Oauth Act as an Oauth consumer

© All rights reserved. Zend Technologies, Inc.35

$config = array( 'callbackUrl' => 'http://example.com/callback', 'siteUrl' => 'http://twitter.com/oauth', 'consumerKey' => 'gg3DsFTW9OU9eWPnbuPzQ', 'consumerSecret' => 'tFB0fyWLSMf74lkEu9FTyoHXcazOWpbrAjTCCK48A');$consumer = new Zend_Oauth_Consumer($config);

// Get request token:$token = $consumer->getRequestToken();

// Persist the token$session = new Zend_Session_Namespace('oauth');$session->token = serialize($token);

// Redirect to oauth provider$consumer->redirect();

$config = array( 'callbackUrl' => 'http://example.com/callback', 'siteUrl' => 'http://twitter.com/oauth', 'consumerKey' => 'gg3DsFTW9OU9eWPnbuPzQ', 'consumerSecret' => 'tFB0fyWLSMf74lkEu9FTyoHXcazOWpbrAjTCCK48A');$consumer = new Zend_Oauth_Consumer($config);

// Get request token:$token = $consumer->getRequestToken();

// Persist the token$session = new Zend_Session_Namespace('oauth');$session->token = serialize($token);

// Redirect to oauth provider$consumer->redirect();

© All rights reserved. Zend Technologies, Inc.36

// Within a controller action, assuming consumer// and session setup above$request = $this->getRequest();if (!$request->isGet() || !isset($session->token)) { // error condition!}$token = $consumer->getAccessToken( $request->getQuery(), unserialize($session->token));// use the token!$client = $token->getHttpClient();// ...

// Within a controller action, assuming consumer// and session setup above$request = $this->getRequest();if (!$request->isGet() || !isset($session->token)) { // error condition!}$token = $consumer->getAccessToken( $request->getQuery(), unserialize($session->token));// use the token!$client = $token->getHttpClient();// ...

© All rights reserved. Zend Technologies, Inc.

Zend_Serializer Serialize PHP to a variety of formats, as

well as deserialize back to PHP Supported formats include:

Igbinary WDDX JSON Active Message Format (AMF) 0 and 3 Python Pickle PHP code or serialization

© All rights reserved. Zend Technologies, Inc.38

$serializer = Zend_Serializer::factory('Json');

$serialized = $serializer->serialize($data);$unserialized = $serializer->unserialize($serialized);

$serializer = Zend_Serializer::factory('Json');

$serialized = $serializer->serialize($data);$unserialized = $serializer->unserialize($serialized);

© All rights reserved. Zend Technologies, Inc.39

New Services

Extending your reach into the cloud

© All rights reserved. Zend Technologies, Inc.

New Service - LiveDocx

•http://www.livedocx.com/

•Best described by this image:

40 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

New Service - LiveDocx

41 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

New Service - LiveDocx

42 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

New Service - LiveDocx

•Other API features:Local & Remote templates

Ability to retrieve information about templates

Input Template formats:• Docx, Doc, RTF, TXD

Output Document formats:• Docx, Doc, Html, RTF, PDF, TXD, TXT

Output Image formats:• BMP, PNG, GIF, TIFF, WMF, JPG

43 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

New Service - DeveloperGarden

•Developer Garden is the name of Deutsche Telekom’s developer community.

•Features of the API:BaseUserService

• Class to manage API quota and user accounting details.

IPLocation• Locale the given IP and returns geo coordinates. Works only with IPs

allocated in the network of the Deutsche Telekom.

LocalSearch• Allows you to search with options nearby or around a given geo

coordinate or city.44 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

New Service - DeveloperGarden

•Features (cont.)SendSMS

• Send a SMS or Flash SMS to a given number.

SMSValidation• You can validate a number to use it with SendSMS for also supply a

back channel.

VoiceCall• Initiates a call between two participants.

ConferenceCall• You can configure a whole conference room with participants for an

adhoc conference or you can also schedule your conference.

45 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

New Service - DeveloperGarden

•Setup a conference call:

46 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

New Service - WindowsAzure

•Windows Azure is the name for Microsoft's Software + Services platform

•Features:Interface to Storage API:

• Blobs

• Tables

Batch processing

• Queues

47 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.

New Service – WindowsAzure

48 Insert->Header & Footer

© All rights reserved. Zend Technologies, Inc.49

Documentation updates

Helping you educate yourself

© All rights reserved. Zend Technologies, Inc.

Versioned Documentation Versioned by minor revision (1.10, 1.9,

1.8, etc.) Search by version

© All rights reserved. Zend Technologies, Inc.

New Rendering Engine Now using PhD

(PHP's Documentation system) to render online docs as well as downloadable docs

Faster rendering time and more flexibility in rendering

Better navigation

© All rights reserved. Zend Technologies, Inc.

Tutorials New manual section, “Learning Zend

Framework” Contains Quick Start, and 8 additional

tutorials Part of the ZF repository, which means:

Versioned Translations will be available New content can be added

© All rights reserved. Zend Technologies, Inc.53

© All rights reserved. Zend Technologies, Inc.

Migration Notes New centralized “Migration Notes”

appendix Migration notes per minor version

© All rights reserved. Zend Technologies, Inc.

Commenting Manual comments, ala php.net, have

been enabled!

© All rights reserved. Zend Technologies, Inc.56

Thank you! Information and resources:

http://framework.zend.com/

Recommended