Your SlideShare is downloading. ×
0
A quick start onZend Framework 2by Enrico Zimuel (enrico@zend.com)Senior Software EngineerZend Framework Core TeamZend Tec...
About me                        • Enrico Zimuel (@ezimuel)                        • Software Engineer since 1996          ...
ZF2 in a slide●   New architecture      ▶   MVC, Di, Events, Service, Module●   Better performance●   Requirement: PHP 5.3...
A new core●   The ZF1 way:       ▶   Singleton, Registry, and             Hard-Coded             Dependencies●   The ZF2 a...
MVC is event driven●   Everything is an event       bootstrap                  route                             dispatch ...
Releases●   ZF2.0.0beta4●   Goal:     ▶   beta5 at the end of June     ▶   ZF 2.0 RC this summer!!!                      ©...
Quick startZend Skeleton Application        © All rights reserved. Zend Technologies, Inc.
Zend Skeleton Application●   A simple, skeleton application using the new MVC    layer and the module system●   How to ins...
Output         © All rights reserved. Zend Technologies, Inc.
Folders tree  config  data  module  public  vendor                © All rights reserved. Zend Technologies, Inc.
Config folder  config         autoload     application.config.php  data  module  public  vendor                    © All r...
Data folder  config  data         cache  module  public  vendor                 © All rights reserved. Zend Technologies, ...
Module folder module     Application                          Name of the module             config                 module...
Public folder  public       images       js       css     .htaccess     index.php                 © All rights reserved. Z...
Vendor folder  config  data  module  public  vendor         zendframework                 © All rights reserved. Zend Tech...
configuration    © All rights reserved. Zend Technologies, Inc.
/config/application.config.php             © All rights reserved. Zend Technologies, Inc.
public folder    © All rights reserved. Zend Technologies, Inc.
public/.htaccessRewriteEngine OnRewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]RewriteCond ...
public/index.php            © All rights reserved. Zend Technologies, Inc.
ZendServiceManager ●   The ServiceManager is a Service Locator     implementation ●   A Service Locator is a well-known ob...
Types of Services ●   Explicit (name => object pairs) ●   Invokables (name => class to instantiate) ●   Factories (name =>...
module © All rights reserved. Zend Technologies, Inc.
Modules by default A module is all related code and assets     that solve a specific problem.Modules inform the MVC about ...
Modules for ZF2●   The basic unit in a ZF2 application    is a Module●   Modules are “Plug and play” technology●   Modules...
Develop Modules●   Modules contain all logic related to a    discrete application problem.       ▶   Controllers       ▶  ...
moduleApplicationModule.php            © All rights reserved. Zend Technologies, Inc.
/module/Application/config/module.config.php(routing part)                © All rights reserved. Zend Technologies, Inc.
/module/Application/config/module.config.php(controller part)                © All rights reserved. Zend Technologies, Inc.
/module/Application/config/module.config.php(view)                © All rights reserved. Zend Technologies, Inc.
/module/Application/src/Application/    Controller/IndexController.php                Passing array() of variables to the ...
Packaging system     © All rights reserved. Zend Technologies, Inc.
Pyrus●   http://packages.zendframework.com/●   Download or use pyrus, a PEAR2 installer●   Pyrus packages:     ▶   Pyrus s...
Composer●   New package management and distribution    tool●   http://packagist.org/●   http://getcomposer.org/           ...
composer.json          © All rights reserved. Zend Technologies, Inc.
From ZF1 to ZF2     © All rights reserved. Zend Technologies, Inc.
From ZF1 to ZF2●   Goal: migrate without rewriting much code!●   Main steps       ▶   Namespace: Zend_Foo => ZendFoo      ...
Conclusion:ZF2 rocks!   © All rights reserved. Zend Technologies, Inc.
Why ZF2 rocks!●   Based on solid architecture principles●   Very fast (focused on optimization)●   Open architecture (even...
We want you!●   How to contribute:    ▶   Write code    ▶   Documentation    ▶   Testing    ▶   Feedbacks/comments        ...
Helping out●   http://framework.zend.com/zf2●   http://github.com/zendframework●   https://github.com/zendframework/ZendSk...
Thank you! ●   Comment this talk at:       ▶   https://joind.in/6237 ●   Direct contact:       ▶   enrico@zend.com       ▶...
Upcoming SlideShare
Loading in...5
×

Quick start on Zend Framework 2

14,724

Published on

Talk presented at the Dutch PHP Conference 2012 in Amsterdam. Hands on the Zend Skeleton Application of ZF 2.0.0beta4

Published in: Technology
0 Comments
14 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
14,724
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
270
Comments
0
Likes
14
Embeds 0
No embeds

No notes for slide

Transcript of "Quick start on Zend Framework 2"

  1. 1. A quick start onZend Framework 2by Enrico Zimuel (enrico@zend.com)Senior Software EngineerZend Framework Core TeamZend Technologies Ltd © All rights reserved. Zend Technologies, Inc.
  2. 2. About me • Enrico Zimuel (@ezimuel) • Software Engineer since 1996 – Assembly x86, C/C++, Java, Perl, PHP • PHP Engineer at Zend Technologies in @ezimuel the Zend Framework Team enrico@zend.com • International speaker on PHP and computer security topics www.zimuel.it • Researcher programmer at Informatics Institute of University of Amsterdam • Co-founder of the PUG Torino (Italy) © All rights reserved. Zend Technologies, Inc.
  3. 3. ZF2 in a slide● New architecture ▶ MVC, Di, Events, Service, Module● Better performance● Requirement: PHP 5.3.3● No more CLA (Contributor License Agreement)● Git (GitHub) instead of SVN● Packaging system ▶ pyrus, composer © All rights reserved. Zend Technologies, Inc.
  4. 4. A new core● The ZF1 way: ▶ Singleton, Registry, and Hard-Coded Dependencies● The ZF2 approach: ▶ Aspect Oriented Design and Dependency Injection © All rights reserved. Zend Technologies, Inc.
  5. 5. MVC is event driven● Everything is an event bootstrap route dispatch Listeners © All rights reserved. Zend Technologies, Inc.
  6. 6. Releases● ZF2.0.0beta4● Goal: ▶ beta5 at the end of June ▶ ZF 2.0 RC this summer!!! © All rights reserved. Zend Technologies, Inc.
  7. 7. Quick startZend Skeleton Application © All rights reserved. Zend Technologies, Inc.
  8. 8. Zend Skeleton Application● A simple, skeleton application using the new MVC layer and the module system● How to install: $ cd my/project/dir $ git clone git://github.com/zendframework/ZendSkeletonApplication.git $ cd ZendSkeletonApplication $ php composer.phar install © All rights reserved. Zend Technologies, Inc.
  9. 9. Output © All rights reserved. Zend Technologies, Inc.
  10. 10. Folders tree config data module public vendor © All rights reserved. Zend Technologies, Inc.
  11. 11. Config folder config autoload application.config.php data module public vendor © All rights reserved. Zend Technologies, Inc.
  12. 12. Data folder config data cache module public vendor © All rights reserved. Zend Technologies, Inc.
  13. 13. Module folder module Application Name of the module config module.config.php src Application Controller IndexController.php view application index index.phtml error layout Module.php © All rights reserved. Zend Technologies, Inc.
  14. 14. Public folder public images js css .htaccess index.php © All rights reserved. Zend Technologies, Inc.
  15. 15. Vendor folder config data module public vendor zendframework © All rights reserved. Zend Technologies, Inc.
  16. 16. configuration © All rights reserved. Zend Technologies, Inc.
  17. 17. /config/application.config.php © All rights reserved. Zend Technologies, Inc.
  18. 18. public folder © All rights reserved. Zend Technologies, Inc.
  19. 19. public/.htaccessRewriteEngine OnRewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^.*$ - [NC,L]RewriteRule ^.*$ index.php [NC,L] © All rights reserved. Zend Technologies, Inc.
  20. 20. public/index.php © All rights reserved. Zend Technologies, Inc.
  21. 21. ZendServiceManager ● The ServiceManager is a Service Locator implementation ● A Service Locator is a well-known object in which you may register objects (more in general services) and later retrieve them ● Driven by configuration © All rights reserved. Zend Technologies, Inc.
  22. 22. Types of Services ● Explicit (name => object pairs) ● Invokables (name => class to instantiate) ● Factories (name => callable returning object) ● Aliases (name => some other name) ● Abstract Factories (unknown services) ● Scoped Containers (limit what can be created) ● Shared (or not; you decide) © All rights reserved. Zend Technologies, Inc.
  23. 23. module © All rights reserved. Zend Technologies, Inc.
  24. 24. Modules by default A module is all related code and assets that solve a specific problem.Modules inform the MVC about services and event listeners © All rights reserved. Zend Technologies, Inc.
  25. 25. Modules for ZF2● The basic unit in a ZF2 application is a Module● Modules are “Plug and play” technology● Modules are simple: ▶ A namespace ▶ Containing a single classfile: Module.php © All rights reserved. Zend Technologies, Inc.
  26. 26. Develop Modules● Modules contain all logic related to a discrete application problem. ▶ Controllers ▶ Entities ▶ Plugins ▶ Etc.● 99% of the time, you will write modules © All rights reserved. Zend Technologies, Inc.
  27. 27. moduleApplicationModule.php © All rights reserved. Zend Technologies, Inc.
  28. 28. /module/Application/config/module.config.php(routing part) © All rights reserved. Zend Technologies, Inc.
  29. 29. /module/Application/config/module.config.php(controller part) © All rights reserved. Zend Technologies, Inc.
  30. 30. /module/Application/config/module.config.php(view) © All rights reserved. Zend Technologies, Inc.
  31. 31. /module/Application/src/Application/ Controller/IndexController.php Passing array() of variables to the view © All rights reserved. Zend Technologies, Inc.
  32. 32. Packaging system © All rights reserved. Zend Technologies, Inc.
  33. 33. Pyrus● http://packages.zendframework.com/● Download or use pyrus, a PEAR2 installer● Pyrus packages: ▶ Pyrus setup ▶ wget http://packages.zendframework.com/pyrus.phar ▶ pyrus.phar . ▶ pyrus.phar . channel­discover packages.zendframework.com ▶ Install a Zend_<component> ▶ pyrus.phar . install zf2/Zend_<component> © All rights reserved. Zend Technologies, Inc.
  34. 34. Composer● New package management and distribution tool● http://packagist.org/● http://getcomposer.org/ © All rights reserved. Zend Technologies, Inc.
  35. 35. composer.json © All rights reserved. Zend Technologies, Inc.
  36. 36. From ZF1 to ZF2 © All rights reserved. Zend Technologies, Inc.
  37. 37. From ZF1 to ZF2● Goal: migrate without rewriting much code!● Main steps ▶ Namespace: Zend_Foo => ZendFoo ▶ Autoloading: 3 options ▶ MVC: module, event based, dispatchable ▶ DB: new ZendDb ▶ Form: new ZendForm● Can run in parallel (instant migration!) © All rights reserved. Zend Technologies, Inc.
  38. 38. Conclusion:ZF2 rocks! © All rights reserved. Zend Technologies, Inc.
  39. 39. Why ZF2 rocks!● Based on solid architecture principles● Very fast (focused on optimization)● Open architecture (event driven)● Support of modules (reuse of the code)● Driven by the community (100% open source)● Completed tested (PHPUnit, Travis CI)● Packages (pyrus, composer) © All rights reserved. Zend Technologies, Inc.
  40. 40. We want you!● How to contribute: ▶ Write code ▶ Documentation ▶ Testing ▶ Feedbacks/comments https://github.com/zendframework/zf2 © All rights reserved. Zend Technologies, Inc.
  41. 41. Helping out● http://framework.zend.com/zf2● http://github.com/zendframework● https://github.com/zendframework/ZendSkeletonApplication● Getting Started with Zend Framework 2 by Rob Allen, http://www.akrabat.com● Weekly IRC meetings (#zf2-meeting on Freenode)● #zftalk.2 on Freenode IRC © All rights reserved. Zend Technologies, Inc.
  42. 42. Thank you! ● Comment this talk at: ▶ https://joind.in/6237 ● Direct contact: ▶ enrico@zend.com ▶ @ezimuel © All rights reserved. Zend Technologies, Inc.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×