Top Banner
Zend Framework 2.0 Whatʼs new? Rob Allen ConFoo March 2011 twitter: @akrabat
35
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Zend Framework 2, What's new, Confoo 2011

Zend Framework 2.0Whatʼs new?

Rob Allen

ConFoo March 2011

twitter: @akrabat

Page 2: Zend Framework 2, What's new, Confoo 2011

Rob Allen?• PHP developer since 1999• Wrote Zend_Config• Tutorial at akrabat.com• Zend Framework in Action!

Next book!

Zend Framework 2 in Action

(with Ryan Mauger)

Page 3: Zend Framework 2, What's new, Confoo 2011

Zend Framework 1.0

Page 4: Zend Framework 2, What's new, Confoo 2011

How we got here• Announced October 2005

• Mar 2006: v0.1 released: not a lot!

• July 2007: v1.0: MVC + cool stuff!

• Mar 2008: v1.5: Form, Layout, Context

• Apr 2009: v1.8: Application, Tool, Nav

• Nov 2010: v1.11: SimpleCloud, UserAgent

Page 5: Zend Framework 2, What's new, Confoo 2011

Where we are today• Zend Framework 1 core is complete

• New components, adapters and plugins are being added

• Widespread usage

• Plenty of help available

Page 6: Zend Framework 2, What's new, Confoo 2011

Problems with ZF1• Learning curve

• Performance

• Too much “magic”

• Inconsistency between components

Page 7: Zend Framework 2, What's new, Confoo 2011

Zend Framework 2.0“The primary thrust of ZF 2.0 is to make a more consistent, well-documented product, improving

developer productivity and runtime performance.”Matthew Weier OʼPhinney

Page 8: Zend Framework 2, What's new, Confoo 2011

Think evolution,not revolution

Page 9: Zend Framework 2, What's new, Confoo 2011

Zend Framework 2Key goals

Page 10: Zend Framework 2, What's new, Confoo 2011

Ease learning curve• Create better documentation

• Cohesive tutorials

• Reference manual

• Address API consistency

• Options

• Language

Page 11: Zend Framework 2, What's new, Confoo 2011

Easier extension• Remove singletons

• Interfaces over abstract classes

• Remove hard-coded dependancies

Page 12: Zend Framework 2, What's new, Confoo 2011

Improve performance• Aiming for 200%+ over ZF 1

• Deployment tools

• Optimise for production

• Documentation

Page 13: Zend Framework 2, What's new, Confoo 2011

Simplify• Focus on core components

• Make code readable

• Consistent APIs

Page 14: Zend Framework 2, What's new, Confoo 2011

Zend Framework 2Key changes

Page 15: Zend Framework 2, What's new, Confoo 2011

“The general theme throughout these milestones is narrowing the scope of components, and ensuring a proper

separation of concerns between components.”

Matthew Weier O’Phinney

Page 16: Zend Framework 2, What's new, Confoo 2011

PHP 5.3 support• Advance the use of PHP 5.3

• Namespaces

• Closures over create_function()

Page 17: Zend Framework 2, What's new, Confoo 2011

Namespaces// library/Nennius/Controller/Plugin/InitAdminLayout.php<?phpnamespace Nennius\Controller\Plugin;use \Zend\Controller\Request\AbstractRequest as Request;use \Zend\Controller\Plugin\AbstractPlugin as Plugin;

class InitAdminLayout extends Plugin{ public function dispatchLoopStartup(Request $request) { $fc = \Zend\Controller\Front::getInstance(); $bootstrap = $fc->getParam('bootstrap'); $layout = $bootstrap->layout; $controllerName = $request->getControllerName(); if (substr($controllerName, 0, 5) == 'admin') { $layout->setLayout('admin'); }}

Page 18: Zend Framework 2, What's new, Confoo 2011

Autoloading• No more include path

• Standard autoloader

• Explicit namespace=>path pairs

• up to 40% performance gain!

• 2: ClassMap autoloader

• pre-built array map (for deployment)

• up to 150% performance gain!

Page 19: Zend Framework 2, What's new, Confoo 2011

Plugin loading• Alias autoloading

• map ʻaliasʼ to class that it represents

• Interface for consistency (clients)

• Plugin broker (central operations)

• Mapping is simpler to explain!

• Much more performant! (up to 5x!)

Page 20: Zend Framework 2, What's new, Confoo 2011

Plugin loading$broker = new Zend\View\HelperBroker(); $loader = $broker->getPluginLoader();

$loader->register('url', 'My\View\Helper\Url');

// get a Zend\View\Helper\BaseUrl$baseUrlHelper = $broker->load('baseUrl');

// get a My\View\Helper\Url$urlHelper = $broker->load('url');

Page 21: Zend Framework 2, What's new, Confoo 2011

Exception handling• Use SPL exceptions for specific catches

• Use an interface for component catches

• Can catch \Exception if you donʼt care :)

Page 22: Zend Framework 2, What's new, Confoo 2011

Exceptionsnamespace My;interface ExceptionInterface {} class Exception implements ExceptionInterface {}class InvalidArgument extends InvalidArgumentException implements ExceptionInterface {}

try { $a = new A(); $a->b($c);}catch (InvalidArgument $e) { die("Invalid arg happened\n");}catch (ExceptionInterface $e) { die("Some error happened\n");}

Page 23: Zend Framework 2, What's new, Confoo 2011

MVC• Will write to the interface!

• Modules as 1st class citizens

• Page controllers

• Service Locator with DI

• Standardise hooks

• View

Page 24: Zend Framework 2, What's new, Confoo 2011

Internationalisation• Improve performance

• Use DateTime

• Fix inconsistencies with PHPʼs APIs

• Remove statics and global states

Page 25: Zend Framework 2, What's new, Confoo 2011

Zend Framework 2Development process

Page 26: Zend Framework 2, What's new, Confoo 2011

git• Smaller barrier to contribution

• Better branching and merging

• ZFʼs git guide: http://bit.ly/zfgit

Page 27: Zend Framework 2, What's new, Confoo 2011

Unit testing• Write to /tmp only

• Separate out test asset classes

• Consistent usage of _files directory

• Lower memory/CPU usage

Page 28: Zend Framework 2, What's new, Confoo 2011

Community Review team• Smooth the proposal process

• Assist new contributors

• “Fix” orphaned components

• Contact:

• IRC: #zftalk.dev on freenode

• Email: [email protected]

Page 29: Zend Framework 2, What's new, Confoo 2011

Milestones• Autoloading & plugin loading

• Exceptions

• MVC

• Testing

• Documentation

• Internationalisation

[in progress]

[done][done]

[proposals in place]

Page 30: Zend Framework 2, What's new, Confoo 2011

When?

Page 31: Zend Framework 2, What's new, Confoo 2011

I have no idea!

Page 32: Zend Framework 2, What's new, Confoo 2011

Summary

Page 33: Zend Framework 2, What's new, Confoo 2011

• Play with the ZF2 snapshots

• Contribute

• Report bugs!

• Comment on proposals: http://bit.ly/zf2wiki

• Need help?

• IRC: #zftalk on freenode

• Mailing list

• Buy Zend Framework 2 in Action

(when released!)

Page 35: Zend Framework 2, What's new, Confoo 2011

Thank youfeedback: http://joind.in/2854

email: [email protected]: @akrabat