SlideShare a Scribd company logo
Submit Search
Upload
Zend Framework 2 quick start
Report
Enrico Zimuel
Senior Software Engineer at Zend Technologies
Follow
•
26 likes
•
9,579 views
1
of
45
Zend Framework 2 quick start
•
26 likes
•
9,579 views
Download Now
Download to read offline
Report
Technology
Zend Framework 2 quick start presentation at ZFCon 2012 of Moscow
Read more
Enrico Zimuel
Senior Software Engineer at Zend Technologies
Follow
Recommended
A quick start on Zend Framework 2
Enrico Zimuel
16.5K views
•
52 slides
Quick start on Zend Framework 2
Enrico Zimuel
12.5K views
•
42 slides
Zend Framework 2 - Basic Components
Mateusz Tymek
5K views
•
24 slides
Zend Framework 2
Tarun Kumar Singhal
1.3K views
•
18 slides
Deprecated: Foundations of Zend Framework 2
Adam Culp
3.4K views
•
45 slides
Zend Framework Introduction
Rafael Monteiro
3.2K views
•
32 slides
More Related Content
What's hot
Zend Framework 2 Components
Shawn Stratton
3.1K views
•
46 slides
Zend Framework 2 Patterns
Zend by Rogue Wave Software
1.9K views
•
61 slides
Get Started with Zend Framework 2
Mindfire Solutions
1.5K views
•
74 slides
ZF2 Presentation @PHP Tour 2011 in Lille
Zend by Rogue Wave Software
1.8K views
•
45 slides
Manage cloud infrastructures in PHP using Zend Framework 2 (and 1)
Enrico Zimuel
3.5K views
•
34 slides
Cryptography with Zend Framework
Enrico Zimuel
3.3K views
•
20 slides
What's hot
(20)
Zend Framework 2 Components
Shawn Stratton
•
3.1K views
Zend Framework 2 Patterns
Zend by Rogue Wave Software
•
1.9K views
Get Started with Zend Framework 2
Mindfire Solutions
•
1.5K views
ZF2 Presentation @PHP Tour 2011 in Lille
Zend by Rogue Wave Software
•
1.8K views
Manage cloud infrastructures in PHP using Zend Framework 2 (and 1)
Enrico Zimuel
•
3.5K views
Cryptography with Zend Framework
Enrico Zimuel
•
3.3K views
Introduction to Zend Framework
Michelangelo van Dam
•
3.8K views
Instant ACLs with Zend Framework 2
Stefano Valle
•
21.6K views
2007 Zend Con Mvc Edited Irmantas
Irmantas Šiupšinskas
•
1.7K views
Extending Zend_Tool
Ralph Schindler
•
1.3K views
Zf2 phpquebec
mkherlakian
•
1.8K views
How to build customizable multitenant web applications - PHPBNL11
Stephan Hochdörfer
•
5.3K views
Using Zend_Tool to Establish Your Project's Skeleton
Jeremy Brown
•
2.1K views
Testing untestable code - phpday
Stephan Hochdörfer
•
1.2K views
A Zend Architecture presentation
techweb08
•
2.2K views
Apigility reloaded
Ralf Eggert
•
1.9K views
Java Code Generation for Productivity
David Noble
•
1.5K views
Symfony2 Service Container: Inject me, my friend
Kirill Chebunin
•
8.2K views
Symfony tips and tricks
Javier Eguiluz
•
54.3K views
Hierarchy Viewer Internals
Kyungmin Lee
•
5.1K views
Similar to Zend Framework 2 quick start
How to Manage Cloud Infrastructures using Zend Framework
Zend by Rogue Wave Software
1K views
•
37 slides
Eclipse HandsOn Workshop
Bastian Feder
1.6K views
•
33 slides
Z ray plugins for dummies
Dmitry Zbarski
415 views
•
54 slides
Getting Native with NDK
ナム-Nam Nguyễn
754 views
•
37 slides
Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)
James Titcumb
483 views
•
104 slides
Php Development With Eclipde PDT
Bastian Feder
2K views
•
32 slides
Similar to Zend Framework 2 quick start
(20)
How to Manage Cloud Infrastructures using Zend Framework
Zend by Rogue Wave Software
•
1K views
Eclipse HandsOn Workshop
Bastian Feder
•
1.6K views
Z ray plugins for dummies
Dmitry Zbarski
•
415 views
Getting Native with NDK
ナム-Nam Nguyễn
•
754 views
Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)
James Titcumb
•
483 views
Php Development With Eclipde PDT
Bastian Feder
•
2K views
Configuration Management and Transforming Legacy Applications in the Enterpri...
Docker, Inc.
•
758 views
Extension and Evolution
Eelco Visser
•
557 views
Bangpypers april-meetup-2012
Deepak Garg
•
528 views
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
Fwdays
•
830 views
Head First Zend Framework - Part 1 Project & Application
Jace Ju
•
3.5K views
debugging in PHP
Jignesh
•
2.9K views
Php7 extensions workshop
julien pauli
•
3.8K views
2010 07-28-testing-zf-apps
Venkata Ramana
•
390 views
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Bastian Feder
•
1.5K views
Eclipse Pdt2.0 26.05.2009
Bastian Feder
•
832 views
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
James Titcumb
•
1.5K views
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Bastian Feder
•
6K views
PHP Development Tools 2.0 - Success Story
Michael Spector
•
1.9K views
Foundations of Zend Framework
Adam Culp
•
975 views
More from Enrico Zimuel
Password (in)security
Enrico Zimuel
10.5K views
•
38 slides
Integrare Zend Framework in Wordpress
Enrico Zimuel
6.6K views
•
38 slides
Introduzione alla Posta Elettronica Certificata (PEC): le regole tecniche
Enrico Zimuel
1.9K views
•
15 slides
PHP goes mobile
Enrico Zimuel
3.3K views
•
24 slides
Zend Framework 2
Enrico Zimuel
3.5K views
•
61 slides
Cryptography in PHP: use cases
Enrico Zimuel
14.5K views
•
36 slides
More from Enrico Zimuel
(20)
Password (in)security
Enrico Zimuel
•
10.5K views
Integrare Zend Framework in Wordpress
Enrico Zimuel
•
6.6K views
Introduzione alla Posta Elettronica Certificata (PEC): le regole tecniche
Enrico Zimuel
•
1.9K views
PHP goes mobile
Enrico Zimuel
•
3.3K views
Zend Framework 2
Enrico Zimuel
•
3.5K views
Cryptography in PHP: use cases
Enrico Zimuel
•
14.5K views
Framework software e Zend Framework
Enrico Zimuel
•
1.1K views
Strong cryptography in PHP
Enrico Zimuel
•
5.7K views
How to scale PHP applications
Enrico Zimuel
•
29.5K views
Velocizzare Joomla! con Zend Server Community Edition
Enrico Zimuel
•
2K views
Zend_Cache: how to improve the performance of PHP applications
Enrico Zimuel
•
6.4K views
XCheck a benchmark checker for XML query processors
Enrico Zimuel
•
819 views
Introduzione alle tabelle hash
Enrico Zimuel
•
662 views
Crittografia quantistica: fantascienza o realtà?
Enrico Zimuel
•
763 views
Introduzione alla crittografia
Enrico Zimuel
•
733 views
Crittografia è sinonimo di sicurezza?
Enrico Zimuel
•
648 views
Sviluppo di applicazioni sicure
Enrico Zimuel
•
390 views
Misure minime di sicurezza informatica
Enrico Zimuel
•
690 views
PHP e crittografia
Enrico Zimuel
•
551 views
La sicurezza delle applicazioni in PHP
Enrico Zimuel
•
431 views
Recently uploaded
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur
Fwdays
39 views
•
31 slides
"How we switched to Kanban and how it integrates with product planning", Vady...
Fwdays
60 views
•
24 slides
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ...
Fwdays
32 views
•
39 slides
Data-centric AI and the convergence of data and model engineering:opportunit...
Paolo Missier
25 views
•
40 slides
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi
102 views
•
17 slides
Combining Orchestration and Choreography for a Clean Architecture
ThomasHeinrichs1
67 views
•
24 slides
Recently uploaded
(20)
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur
Fwdays
•
39 views
"How we switched to Kanban and how it integrates with product planning", Vady...
Fwdays
•
60 views
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ...
Fwdays
•
32 views
Data-centric AI and the convergence of data and model engineering:opportunit...
Paolo Missier
•
25 views
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi
•
102 views
Combining Orchestration and Choreography for a Clean Architecture
ThomasHeinrichs1
•
67 views
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy
Fwdays
•
38 views
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
Prity Khastgir IPR Strategic India Patent Attorney Amplify Innovation
•
24 views
GigaIO: The March of Composability Onward to Memory with CXL
CXL Forum
•
122 views
"AI Startup Growth from Idea to 1M ARR", Oleksandr Uspenskyi
Fwdays
•
25 views
.conf Go 2023 - Data analysis as a routine
Splunk
•
85 views
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
Splunk
•
82 views
AMD: 4th Generation EPYC CXL Demo
CXL Forum
•
123 views
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
NUS-ISS
•
23 views
[2023] Putting the R! in R&D.pdf
Eleanor McHugh
•
36 views
TE Connectivity: Card Edge Interconnects
CXL Forum
•
95 views
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst
•
422 views
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang
•
34 views
Future of Learning - Yap Aye Wee.pdf
NUS-ISS
•
37 views
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada
•
103 views
Zend Framework 2 quick start
1.
Zend Framework 2 quick
start by Enrico Zimuel (enrico@zend.com) Senior Software Engineer Zend Framework Core Team Zend Technologies Ltd ZFConf – 21th April 2012 Moscow © All rights reserved. Zend Technologies, Inc.
2.
About me
• Enrico Zimuel (@ezimuel) • Software Engineer since 1996 – Assembly x86, C/C++, Java, Perl, PHP • Enjoying PHP since 1999 • PHP Engineer at Zend since 2008 • Zend Framework Core Team from 2011 • B.Sc. Computer Science and Economics from University of Pescara (Italy) © All rights reserved. Zend Technologies, Inc.
3.
Summary ●
Overview of ZF2 ● The new autoloading system ● Dependency Injection ● Event manager ● The new MVC ● Quick start: ZendSkeletonApplication ● Package system ● From ZF1 to ZF2 © All rights reserved. Zend Technologies, Inc.
4.
ZF2 key features ●
New architecture (MVC, Di, Events) ● Requirement: PHP 5.3 ● No more CLA (Contributor License Agreement) ● Git (GitHub) instead of SVN ● Better performance ● Module management ● Packaging system © All rights reserved. Zend Technologies, Inc.
5.
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.
6.
New architectural approach ●
Methodologies used in the development – Decoupling (ZendDi) – Event driven (ZendEventManager) – Standard classes (ZendStdlib) ● Take advantage of PHP 5.3 ▶ Namespace ▶ Lambda Functions and Closures ▶ Better performance © All rights reserved. Zend Technologies, Inc.
7.
Autoloading ©
All rights reserved. Zend Technologies, Inc.
8.
Autoloading ●
No more require_once calls! ● Multiple approaches: – ZF1-style include_path autoloader – Per-namespace/prefix autoloading – Class-map autoloading © All rights reserved. Zend Technologies, Inc.
9.
Classmap generator ●
How to generate the .classmap.php? We provided a command line tool: bin/classmap_generator.php ● Usage is trivial: $ cd your/library $ php /path/to/classmap_generator.php -w ● Class-Map will be created in .classmap.php © All rights reserved. Zend Technologies, Inc.
10.
Performance improvement ●
Class-Maps show a 25% improvement on the ZF1 autoloader when no acceleration is present ▶ 60-85% improvements when an opcode cache is in place! ● Pairing namespaces/prefixes with specific paths shows >10% gains with no acceleration ▶ 40% improvements when an opcode cache is in place! Note: The new autoloading system of ZF2 has been ported to ZF 1.12 © All rights reserved. Zend Technologies, Inc.
11.
Dependency Injection
© All rights reserved. Zend Technologies, Inc.
12.
Dependency injection ●
How to manage dependencies between objects? ● Dependency injection (Di) is a design pattern whose purpose is to reduce the coupling between software components It's time for your dependency injection! © All rights reserved. Zend Technologies, Inc.
13.
Di by construct
Without Di With Di (construct) class Foo { class Foo { protected $bar; protected $bar; … … public function __construct() { public function $this->bar= new Bar(); __construct(Bar $bar) { } $this->bar = $bar; … } } … } Cons: Pros: Difficult to test Easy to test No isolation Decoupling Difficult to reuse code Flexible architecture © All rights reserved. Zend Technologies, Inc.
14.
Di by setter class
Foo { protected $bar; … public function setBar(Bar $bar) { $this->bar = $bar; } … } © All rights reserved. Zend Technologies, Inc.
15.
ZendDi ●
Supports the 3 different injection patterns: – Constructor – Interface – Setter ● Implements a Di Container: – Manage the dependencies using configuration and annotation – Provide a compiler to autodiscover classes in a path and create the class definitions, for dependencies © All rights reserved. Zend Technologies, Inc.
16.
Sample definition $definition
= array( 'Foo' => array( 'setBar' => array( 'bar' => array( 'type' => 'Bar', 'required' => true, ), ), ), ); © All rights reserved. Zend Technologies, Inc.
17.
Using the Di
container use ZendDiDi, ZendDiConfiguration; $di = new Di; $config = new Configuration(array( 'definition' => array('class' => $definition) )); $config->configure($di); $foo = $di->get('Foo'); // contains Bar! © All rights reserved. Zend Technologies, Inc.
18.
Di by annotation namespace
Example { use ZendDiDefinitionAnnotation as Di; class Foo { public $bam; /** * @DiInject() */ public function setBar(Bar $bar){ $this->bar = $bar; } } class Bar { } } © All rights reserved. Zend Technologies, Inc.
19.
Di by annotation
(2) $compiler = new ZendDiDefinitionCompilerDefinition(); $compiler->addDirectory('File path of Foo and Bar'); $compiler->compile(); $definitions = new ZendDiDefinitionList($compiler); $di = new ZendDiDi($definitions); $baz = $di->get('ExampleFoo'); // contains Bar! More use cases of ZendDi: https://github.com/ralphschindler/zf2-di-use-cases © All rights reserved. Zend Technologies, Inc.
20.
Event Manager
© All rights reserved. Zend Technologies, Inc.
21.
Event Manager ●
An Event Manager is an object that aggregates listeners for one or more named events, and which triggers events. ● A Listener is a callback that can react to an event. ● An Event is an action. © All rights reserved. Zend Technologies, Inc.
22.
Example use ZendEventManagerEventManager; $events =
new EventManager(); $events->attach('do', function($e) { $event = $e->getName(); $params = $e->getParams(); printf( 'Handled event “%s”, with parameters %s', $event, json_encode($params) ); }); $params = array('foo' => 'bar', 'baz' => 'bat'); $events->trigger('do', null, $params); © All rights reserved. Zend Technologies, Inc.
23.
MVC © All rights
reserved. Zend Technologies, Inc.
24.
Event driven architecture ●
Flow: bootstrap, route, dispatch, response ● Everything is an event in MVC of ZF2 © All rights reserved. Zend Technologies, Inc.
25.
Modules ●
The basic unit in a ZF2 MVC application is a Module ● A module is a collection of code and other files that solves a more specific atomic problem of the larger business problem ● Modules are simply: ▶ A namespace ▶ Containing a single classfile, Module.php © All rights reserved. Zend Technologies, Inc.
26.
Quick start ZendSkeletonApplication
© All rights reserved. Zend Technologies, Inc.
27.
ZendSkeletonApplication ●
A simple, skeleton application using the ZF2 MVC layer and module systems ● On GitHub: ▶ git clone --recursive git://github.com/zendframework/ZendSkeletonApplication.git ● This project makes use of Git submodules ● Works using ZF2.0.0beta3 © All rights reserved. Zend Technologies, Inc.
28.
Folder tree
config autoload application.config.php data module Application config vendor src public Application css Controller IndexController.php images view js Module.php .htaccess autoload_classmap.php index.php autoload_function.php autoload_register.php © All rights reserved. Zend Technologies, Inc.
29.
Output
© All rights reserved. Zend Technologies, Inc.
30.
index.php chdir(dirname(__DIR__)); require_once (getenv('ZF2_PATH') ?: 'vendor/ZendFramework/library')
. '/Zend/Loader/AutoloaderFactory.php'; ZendLoaderAutoloaderFactory::factory(); $appConfig = include 'config/application.config.php'; $listenerOptions = new ZendModuleListenerListenerOptions( $appConfig['module_listener_options']); $defaultListeners = new ZendModuleListenerDefaultListenerAggregate($listenerOptions); $defaultListeners->getConfigListener() ->addConfigGlobPath("config/autoload/{,*.} {global,local}.config.php"); ... © All rights reserved. Zend Technologies, Inc.
31.
index.php (2) ... $moduleManager =
new ZendModuleManager($appConfig['modules']); $moduleManager->events()->attachAggregate($defaultListeners); $moduleManager->loadModules(); // Create application, bootstrap, and run $bootstrap = new ZendMvcBootstrap( $defaultListeners->getConfigListener()->getMergedConfig()); $application = new ZendMvcApplication; $bootstrap->bootstrap($application); $application->run()->send(); © All rights reserved. Zend Technologies, Inc.
32.
config/application.config.php return array(
'modules' => array( 'Application' ), 'module_listener_options' => array( 'config_cache_enabled' => false, 'cache_dir' => 'data/cache', 'module_paths' => array( './module', './vendor', ), ), ); © All rights reserved. Zend Technologies, Inc.
33.
config/autoload ●
global.config.php ● local.config.php.dist (.gitignore) ● By default, this application is configured to load all configs in: ./config/autoload/{,*.}{global,local}.config.php. ● Doing this provides a location for a developer to drop in configuration override files provided by modules, as well as cleanly provide individual, application-wide config files for things like database connections, etc. © All rights reserved. Zend Technologies, Inc.
34.
Application/config/module.config.php return
array( 'di' => array( 'instance' => array( … ) ) ); Here you configure the components of your application (i.e. routing, controller, view) © All rights reserved. Zend Technologies, Inc.
35.
IndexController.php namespace ApplicationController; use ZendMvcControllerActionController,
ZendViewModelViewModel; class IndexController extends ActionController { public function indexAction() { return new ViewModel(); } } © All rights reserved. Zend Technologies, Inc.
36.
Modules are “plug
and play” ● Easy to reuse a module, only 3 steps: 1) Copy the module in module (or vendor) folder 2) Enable the module in your application.config.php ▶ Add the name of the module in “modules” 3) Copy the config file of the module in /config/autoload/module.<module's name>.config.php © All rights reserved. Zend Technologies, Inc.
37.
modules.zendframework.com
© All rights reserved. Zend Technologies, Inc.
38.
Package system
© All rights reserved. Zend Technologies, Inc.
39.
Package system ●
We use Pyrus, a tool to manage PEAR packages. Pyrus simplifies and improves the PEAR experience. ● Source packages (download + github): ▶ http://packages.zendframework.com/ ● Install and configure pyrus: ▶ 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.
40.
From ZF1 to
ZF2 © All rights reserved. Zend Technologies, Inc.
41.
Migrate to ZF2 ●
Goal: migrate without rewriting much code! ● Main steps – Namespace: Zend_Foo => ZendFoo – Exceptions: an Interface for each components, no more Zend_Exception – Autoloading: 3 possible options (one is ZF1) ▶ MVC: module, event based, dispatchable © All rights reserved. Zend Technologies, Inc.
42.
ZF1 migration prototype ●
Source code: http://bit.ly/pvc0X1 ● Creates a "Zf1Compat" version of the ZF1 dispatcher as an event listener. ● The bootstrap largely mimics how ZF1's Zend_Application bootstrap works. ● The default route utilizes the new ZF2 MVC routing, but mimics what ZF1 provided. © All rights reserved. Zend Technologies, Inc.
43.
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.
44.
Questions?
© All rights reserved. Zend Technologies, Inc.
45.
Thank you! ●
Comments and feedbacks: – Email: enrico@zend.com – Twitter: @ezimuel © All rights reserved. Zend Technologies, Inc.