SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
Practical ZF1 to ZF2 Migration:
Lessons from the Field
Clark Everetts,
Zend Technologies, Inc.
2
What are we going to talk about?
Getting from Here to Here
Higher-Level
(ROI, Organizational, Planning, Goals, Constraints)
Lower-Level
(Coding Suggestions, Tools, Resources, Best Practices)
Suggestions / Best Practices
3
•Clark Everetts
– Professional Services Consultant for Zend Technologies
– Onsite and Remote Consulting – Linux, IBM iSeries, Windows
●
Software Architecture Audits and Code Reviews
●
Performance Audits
●
Continuous Delivery Assessments
– Online / Onsite Training in PHP, ZF, Studio, Server, etc.
– SmartStarts: Training and Onsite Guided Development
•Past Life: Independent Consultant (2002 - 2012)
– Web Sites and Web Applications
– Contract Instructor for Zend
•Past, Past Life: Contractor for US Army and NASA (1990 - 2002)
– Interceptor Ground Control Software; Green Screen Db Applications
– Space Station: Real-time, Embedded Software; Science Platforms,
Life Support
Who am I?
4
•Your role: Manager, developer, stakeholder/decision-maker?
•Size: Small to large companies; small to large dev teams
•Have you migrated applications from ZF1 to ZF2?
•Migrating now? How far along in the process are you?
•What challenges did you face / are you facing?
•What tools did you use, or wish existed?
•What did you do before you started?
•Did you expect to accomplish anything besides “the
migration?”
Who are You?
What (I think) You Want to Know
•Available Tools? How much do they do?
•Low-hanging fruit; most difficulties?
•Cost/Benefit? Expected gains?
– Short-term?
– Long-term?
– When not to migrate?
•How to plan a migration; what factors affect the planning?
•Developer skills / skill levels required?
•Budget, schedule is expected for a given project size?
•Other resources?
6
•Zend's Collective Experience
– Planning, Guiding, Implementing Migrations
Where this talk comes from
7
The Prospect of Migration...
8
•Write new ZF2 application from scratch?
•Run ZF1 and ZF2 side-by-side?
– Use ZF2 components in existing ZF1 application
– Use ZF1 components in new ZF2 application
– Some URLs (existing capabilities) ZF1, with other URLs
(entirely new features) implemented in ZF2
– Convert models, controllers, utility functions, helpers,
etc.
•Which ZF2 components are easiest to use in a ZF1 app?
Decisions, decisions...
More Decisions!
•New URLs for new features of application: can do in ZF2, but will likely rely
upon existing ZF1 models, helpers, etc., especially if you took the effort to
make those components reusable in the first place
•Build and test ZF2 version and then cut over from old site to new one, or
iterate existing ZF1 production site into a new ZF2-based site?
•Select a minimum PHP version
– PHP 5.3.3 is minimum for ZF2; current are 5.5.4 and 5.4.20. PHP
5.3.27+ will receive only security fixes through much of 2014 (Zend
supports PHP 5.2 for Enterprise customers on particular product
versions; will continue to support PHP 5.3)
– Consider most recent PHP version you can; this implies parallel
migrations (PHP version as well as ZF2), Look at
http://php.net/ChangeLog-5.php for removal of /changes to legacy
features and new capabilities
– Consider impact to other PHP apps on the server
10
No One Migration Strategy to Rule Them All
There is no single, one-size-fits all, “correct” migration path for all
applications and organizations.
Many factors, including project size, team size and experience with ZF1
and ZF2, structure and quality of the ZF1 codebase, all affect the path to
take.
* http://ligh7bulb.deviantart.com/
*
Remember the Planned Migration Layer?
•Remember the planned Migration Layer?
– Was to allow ZF1 code to run on the ZF2 “engine”
– Work started during ZF2 betas; too much change between beta
releases to keep such a tool current
– Emulating ZF1 behaviour in ZF2 would have taken unacceptable
amount of developer time away from ZF2 development
•Though many people desired it, a full Migration Layer isn't strictly necessary
– PHP 5.3 Namespaces
– Migration: tedious, but not as hard as you think
●
Depends on the code you're starting with!
●
Fat controllers w/ data access, business logic, HTML :-(
Some Tools Exist to Help
•ZF2 Documentation Page
http://framework.zend.com/manual/2.2/en/migration/overview.html
●
GitHub: EvanDotPro/zf-2-for-1
ZF2 Form View Helpers, could be extended to other features
• GitHib: prolic/HumusMvcSkeletonApplication
integrates ModuleManager and ServiceManager into ZF1 application
See http://www.sasaprolic.com/2012/10/when-migration-to-zend-
framework-2.html
13
ZF1 Compatibility Module - Overview
•Custom ZF2 Module that you write – simple, straightforward
•Use existing ZF1-based application resources with minimal
initial code rewrite:
– Database
– Translation
– Session
•That is, Any Zend_Application_Resource plugin
•Obtain and use these resources as ZF2 Services via
ServiceManager
•Only for Application-wide, “global” resources
14
The Prospect of Migration...
Starting to Feel Better?
15
•What you do depends on what you want
– Delay a complete rewrite
●
Phased approach, reusing much of your ZF1 code
– Refactor and clean up “bad” code
•Smaller Application, perhaps non mission-critical
– Rewrite, use as a learning experience for a larger
migration effort
Planning
16
// config/application.config.php
'modules' => array(
'Application',
'Zf1', // <-- your ZF1 compatibility module
// you will add other modules to the list as you
progress
),
// remainder of config array
ZF1 Compatibility Module – Add Module to config
17
// module/Zf1/Module.php
namespace Zf1;
use ZendModuleManagerFeatureAutoloaderProviderInterface;
use ZendMvcMvcEvent;
class Module implements AutoloaderProviderInterface
{
public function getAutoloaderConfig()
{
$zf1path = getenv('ZF1_PATH'); // SetEnv in Apache vhost/.htaccess
if (!$zf1path) { throw new Exception('Define ZF1 library path'); }
/// more coming...
ZF1 Compatibility Module – Autoload ZF1 Classes
18
// module/Zf1/Module.php getAutoloaderConfig()
return array(
'ZendLoaderStandardAutoloader' => array (
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' .
str_replace('', '/', __NAMESPACE__)
),
'prefixes' => array('Zend' => $zf1path)
)
);
ZF1 Compatibility Module – Autoload ZF1 (cont.)
19
// module/Zf1/config/module.config.php
'service_manager' => array (
'factories' => array(
'zf1-db' => 'Zf1ServiceFactoryDatabase',
'zf1-translate'=> 'Zf1ServiceFactoryTranslate',
// other ZF1-based resources...
),
'aliases' => array (
'translate' => 'zf1-translate',
)
)
ZF1 Compat. Module – Resources become Services
20
ZF1 Compat. Module – Factories to Create Services
namespace Zf1ServiceFactory;
use ZendServiceManager;
class Database implements ServiceManagerFactoryInterface {
public function createService(
ServiceManagerServiceLocatorInterface $serviceLocator
)
{
$config = $serviceLocator->get('config');
$adapter = Zend_Db::factory(
$config['zf1-db']['adapter'],
$config['zf1-db']['params']
);
return $adapter;
}
}
21
ZF1 Compatibility Module – Register the Services
// module/Zf1/Module.php
public function onBootstrap(MvcEvent $e)
{
$services = $e->getApplication()->getServiceManager();
$dbAdapter = $services->get('zf1-db');
Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
// Perhaps your views need config. For now, in views, access config
// directly via registry. Later, use code that injects config into view
$config = $services->get('config');
Zend_Registry::set('config', Util::arrayToObject($config));
// In audits, we often find ZF1 models accessing the db via registry
// What you see here is not “best practice,” but a baby step toward
// injecting this dependency in a later phase of migration
$database = $services->get('zf1-db');
Zend_Registry::set('database', $database);
$services = $e->getApplication()->getServiceManager();
Zend_Registry::set('session', $services->get('auth')->getStorage()-
>read());
}
22
ZF1 Compatibility Module – Review
•Temporary, stop-gap measure for reusing ZF1 resources
•Avoids major up-front rewrite
•Obtain and use these resources as ZF2 Services via
ServiceManager:
– Add it to the list of modules used by your ZF2 app
– Set up autoloading to find ZF1 library
– Identify Resources as Services to the ServiceManager
– Write Factories to create the services
– Register the Services
•Only for Application-wide, “global” resources
•Remember: This Module will GO AWAY in a later phase!
23
The Prospect of Migration...
How are you
feeling?
24
Reusing ZF1 Configuration - Overview
•ZF1 Configuration – .ini, .xml, .json, .yaml
•ZF2 Configuration – arrays
•Reuse existing ZF1 configuration files in ZF2 application
25
Reusing ZF1 Configuration - .ini files
// module/SomeModule/Module.php
public function getConfig ()
{
$path = __DIR__ . '/config/config.ini';
$config = new Zend_Config_Ini($path, $section);
$oldConfig = $config->toArray();
if (defined('ZF1_COMPAT')) {
$oldConfig['zf1-db'] = $oldConfig['db']; }
// Fix 1: for the database options
$dbParams = array ('driver' => $oldConfig['db']['adapter']);
$dbParams = array_merge($dbParams, $oldConfig['db']['params']);
$oldConfig['db'] = $dbParams;
$phpConfig = include __DIR__ . '/config/module.config.php';
return array_merge($oldConfig, $phpConfig);
}
26
Reuse ZF1 Models - Autoloading
// module/SomeModule/Module.php
public function getAutoloaderConfig ()
{
return array(
'ZendLoaderClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php'
),
'ZendLoaderStandardAutoloader' => array (
'namespaces' => array(
// if we're in a namespace deeper than one level we need to
// fix the  in the path
__NAMESPACE__ => __DIR__ . '/src/' . str_replace('', '/',
__NAMESPACE__)
),
'prefixes' => array(// This goes away in later phase
'Model' => __DIR__ .'/src/' . str_replace('', '/', __NAMESPACE__)
. '/Model',
)
)
);
}
27
Reuse ZF1 Models – Merge config with ZF2 config
// module/SomeModule/Module.php
public function getConfig ()
{
include __DIR__ . '/config/config.php';
$path = __DIR__ . '/config/config.ini';
$config = new Zend_Config_Ini($path, $section);
$oldConfig = $config->toArray();
if (defined('ZF1_COMPAT')) {
$oldConfig['zf1-db'] = $oldConfig['db'];
}
// database options from db section of config.ini
$dbParams = array('driver' => $oldConfig['db']['adapter']);
$dbParams = array_merge($dbParams, $oldConfig['db']['params']);
$oldConfig['db'] = $dbParams;
$phpConfig = include __DIR__ . '/config/module.config.php';
return array_merge($oldConfig, $phpConfig);
}
Opportunity for refactoring
Thank You!
Please give constructive feedback at
https://joind.in/9083
Email: clark.e@zend.com
https://github.com/clarkphp
Twitter: @clarkphp

Weitere ähnliche Inhalte

Was ist angesagt?

Browser tools that make web development easier
Browser tools that make web development easierBrowser tools that make web development easier
Browser tools that make web development easierAlan Seiden
 
Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Paul Jones
 
Zend Products and PHP for IBMi
Zend Products and PHP for IBMi  Zend Products and PHP for IBMi
Zend Products and PHP for IBMi Shlomo Vanunu
 
Edp bootstrapping a-software_company
Edp bootstrapping a-software_companyEdp bootstrapping a-software_company
Edp bootstrapping a-software_companyGanesh Kulkarni
 
La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!Ulrich Krause
 
KYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under ControlKYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under ControlCoimbra JUG
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules uploadRyan Cuprak
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeansRyan Cuprak
 
Mixing Plone and Django for explosive results
Mixing Plone and Django for explosive resultsMixing Plone and Django for explosive results
Mixing Plone and Django for explosive resultsSimone Deponti
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in productionChristian Papauschek
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCUlrich Krause
 
Workshop Framework(J2EE/OSGi/RCP)
Workshop Framework(J2EE/OSGi/RCP)Workshop Framework(J2EE/OSGi/RCP)
Workshop Framework(J2EE/OSGi/RCP)Summer Lu
 
“Bootify your app - from zero to hero
“Bootify  your app - from zero to hero“Bootify  your app - from zero to hero
“Bootify your app - from zero to heroIzzet Mustafaiev
 
Testing Alfresco extensions
Testing Alfresco extensionsTesting Alfresco extensions
Testing Alfresco extensionsITD Systems
 
An Introduction to Play 2 Framework
An Introduction to Play 2 FrameworkAn Introduction to Play 2 Framework
An Introduction to Play 2 FrameworkPT.JUG
 

Was ist angesagt? (19)

Browser tools that make web development easier
Browser tools that make web development easierBrowser tools that make web development easier
Browser tools that make web development easier
 
Git preso to valtech cfml team
Git preso to valtech cfml teamGit preso to valtech cfml team
Git preso to valtech cfml team
 
Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)
 
Zend Products and PHP for IBMi
Zend Products and PHP for IBMi  Zend Products and PHP for IBMi
Zend Products and PHP for IBMi
 
Edp bootstrapping a-software_company
Edp bootstrapping a-software_companyEdp bootstrapping a-software_company
Edp bootstrapping a-software_company
 
La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!
 
Zend Framework
Zend FrameworkZend Framework
Zend Framework
 
KYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under ControlKYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under Control
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Developing better PHP projects
Developing better PHP projectsDeveloping better PHP projects
Developing better PHP projects
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
Mixing Plone and Django for explosive results
Mixing Plone and Django for explosive resultsMixing Plone and Django for explosive results
Mixing Plone and Django for explosive results
 
Zend
ZendZend
Zend
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in production
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
Workshop Framework(J2EE/OSGi/RCP)
Workshop Framework(J2EE/OSGi/RCP)Workshop Framework(J2EE/OSGi/RCP)
Workshop Framework(J2EE/OSGi/RCP)
 
“Bootify your app - from zero to hero
“Bootify  your app - from zero to hero“Bootify  your app - from zero to hero
“Bootify your app - from zero to hero
 
Testing Alfresco extensions
Testing Alfresco extensionsTesting Alfresco extensions
Testing Alfresco extensions
 
An Introduction to Play 2 Framework
An Introduction to Play 2 FrameworkAn Introduction to Play 2 Framework
An Introduction to Play 2 Framework
 

Andere mochten auch

Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learnedMoving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learnedBaldur Rensch
 
2012 deep research report on china special steel industry
2012 deep research report on china special steel industry2012 deep research report on china special steel industry
2012 deep research report on china special steel industrysmarter2011
 
Skills And Competence A Lifespan Perspective Public
Skills And Competence A Lifespan Perspective PublicSkills And Competence A Lifespan Perspective Public
Skills And Competence A Lifespan Perspective PublicLeo Casey
 
Top 10 Tips from Millionaires
Top 10 Tips from MillionairesTop 10 Tips from Millionaires
Top 10 Tips from Millionairesmaemis
 
CV_Zhang Haochenzi 2015:10:08
CV_Zhang Haochenzi 2015:10:08CV_Zhang Haochenzi 2015:10:08
CV_Zhang Haochenzi 2015:10:08haochenzi zhang
 
Using Oracle Applications on your iPad
Using Oracle Applications on your iPadUsing Oracle Applications on your iPad
Using Oracle Applications on your iPadOracle Day
 
مفهوم الضرر بين الشرع والطب
مفهوم الضرر بين الشرع والطبمفهوم الضرر بين الشرع والطب
مفهوم الضرر بين الشرع والطبDr Ghaiath Hussein
 
Q2 2013 ASSA ABLOY investors presentation 19 july
Q2 2013 ASSA ABLOY investors presentation 19 julyQ2 2013 ASSA ABLOY investors presentation 19 july
Q2 2013 ASSA ABLOY investors presentation 19 julyASSA ABLOY
 
SAP Business Object Material
SAP Business Object Material SAP Business Object Material
SAP Business Object Material erpsoln
 
Open stack in action cern _openstack_accelerating_science
Open stack in action  cern _openstack_accelerating_scienceOpen stack in action  cern _openstack_accelerating_science
Open stack in action cern _openstack_accelerating_scienceeNovance
 
Respeaking as a part of translation and interpreting curriculum
Respeaking as a part of translation and interpreting curriculumRespeaking as a part of translation and interpreting curriculum
Respeaking as a part of translation and interpreting curriculumUniversity of Warsaw
 
The Invention of Capitalism - Michael Perelman
The Invention of Capitalism - Michael PerelmanThe Invention of Capitalism - Michael Perelman
The Invention of Capitalism - Michael Perelmanberat celik
 

Andere mochten auch (20)

Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learnedMoving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
Moving a high traffic ZF1 Enterprise Application to SF2 - Lessons learned
 
NEC Japan
NEC JapanNEC Japan
NEC Japan
 
2012 deep research report on china special steel industry
2012 deep research report on china special steel industry2012 deep research report on china special steel industry
2012 deep research report on china special steel industry
 
Tema 08
Tema 08Tema 08
Tema 08
 
Skills And Competence A Lifespan Perspective Public
Skills And Competence A Lifespan Perspective PublicSkills And Competence A Lifespan Perspective Public
Skills And Competence A Lifespan Perspective Public
 
Child domestic labor handbook
Child domestic labor handbookChild domestic labor handbook
Child domestic labor handbook
 
Top 10 Tips from Millionaires
Top 10 Tips from MillionairesTop 10 Tips from Millionaires
Top 10 Tips from Millionaires
 
CV_Zhang Haochenzi 2015:10:08
CV_Zhang Haochenzi 2015:10:08CV_Zhang Haochenzi 2015:10:08
CV_Zhang Haochenzi 2015:10:08
 
Using Oracle Applications on your iPad
Using Oracle Applications on your iPadUsing Oracle Applications on your iPad
Using Oracle Applications on your iPad
 
مفهوم الضرر بين الشرع والطب
مفهوم الضرر بين الشرع والطبمفهوم الضرر بين الشرع والطب
مفهوم الضرر بين الشرع والطب
 
Primary EFL Reading Competition
Primary EFL Reading CompetitionPrimary EFL Reading Competition
Primary EFL Reading Competition
 
工作人生
工作人生工作人生
工作人生
 
Q2 2013 ASSA ABLOY investors presentation 19 july
Q2 2013 ASSA ABLOY investors presentation 19 julyQ2 2013 ASSA ABLOY investors presentation 19 july
Q2 2013 ASSA ABLOY investors presentation 19 july
 
SAP Business Object Material
SAP Business Object Material SAP Business Object Material
SAP Business Object Material
 
JS basics
JS basicsJS basics
JS basics
 
Open stack in action cern _openstack_accelerating_science
Open stack in action  cern _openstack_accelerating_scienceOpen stack in action  cern _openstack_accelerating_science
Open stack in action cern _openstack_accelerating_science
 
Respeaking as a part of translation and interpreting curriculum
Respeaking as a part of translation and interpreting curriculumRespeaking as a part of translation and interpreting curriculum
Respeaking as a part of translation and interpreting curriculum
 
The Invention of Capitalism - Michael Perelman
The Invention of Capitalism - Michael PerelmanThe Invention of Capitalism - Michael Perelman
The Invention of Capitalism - Michael Perelman
 
Portugal Global Times Feature
Portugal Global Times FeaturePortugal Global Times Feature
Portugal Global Times Feature
 
Status report1
Status report1Status report1
Status report1
 

Ähnlich wie Zend con practical-zf1-zf2-migration

Extending ZF & Extending With ZF
Extending ZF & Extending With ZFExtending ZF & Extending With ZF
Extending ZF & Extending With ZFRalph Schindler
 
SD PHP Zend Framework
SD PHP Zend FrameworkSD PHP Zend Framework
SD PHP Zend Frameworkphilipjting
 
ZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularityZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularityJohn Coggeshall
 
faastRuby - Building a FaaS platform with Redis (RedisConf19)
faastRuby - Building a FaaS platform with Redis (RedisConf19)faastRuby - Building a FaaS platform with Redis (RedisConf19)
faastRuby - Building a FaaS platform with Redis (RedisConf19)Paulo Arruda
 
Building A FaaA Platform With Redis: Paulo Arruda
Building A FaaA Platform With Redis: Paulo ArrudaBuilding A FaaA Platform With Redis: Paulo Arruda
Building A FaaA Platform With Redis: Paulo ArrudaRedis Labs
 
Puppet camp london nov 2014 slides (1)
Puppet camp london nov 2014   slides (1)Puppet camp london nov 2014   slides (1)
Puppet camp london nov 2014 slides (1)Puppet
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfssuser705051
 
A quick start on Zend Framework 2
A quick start on Zend Framework 2A quick start on Zend Framework 2
A quick start on Zend Framework 2Enrico Zimuel
 
Expressive Microservice Framework Blastoff
Expressive Microservice Framework BlastoffExpressive Microservice Framework Blastoff
Expressive Microservice Framework BlastoffAdam Culp
 
Zend expressive workshop
Zend expressive workshopZend expressive workshop
Zend expressive workshopAdam Culp
 
Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Paul Jones
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Mack Hardy
 
z13: New Opportunities – if you dare!
z13: New Opportunities – if you dare!z13: New Opportunities – if you dare!
z13: New Opportunities – if you dare!Michael Erichsen
 
ZF2: Writing Service Components
ZF2: Writing Service ComponentsZF2: Writing Service Components
ZF2: Writing Service ComponentsMike Willbanks
 

Ähnlich wie Zend con practical-zf1-zf2-migration (20)

Extending ZF & Extending With ZF
Extending ZF & Extending With ZFExtending ZF & Extending With ZF
Extending ZF & Extending With ZF
 
SD PHP Zend Framework
SD PHP Zend FrameworkSD PHP Zend Framework
SD PHP Zend Framework
 
Frameworks choice
Frameworks choiceFrameworks choice
Frameworks choice
 
ZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularityZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularity
 
Serverless design with Fn project
Serverless design with Fn projectServerless design with Fn project
Serverless design with Fn project
 
faastRuby - Building a FaaS platform with Redis (RedisConf19)
faastRuby - Building a FaaS platform with Redis (RedisConf19)faastRuby - Building a FaaS platform with Redis (RedisConf19)
faastRuby - Building a FaaS platform with Redis (RedisConf19)
 
Building A FaaA Platform With Redis: Paulo Arruda
Building A FaaA Platform With Redis: Paulo ArrudaBuilding A FaaA Platform With Redis: Paulo Arruda
Building A FaaA Platform With Redis: Paulo Arruda
 
Gulp overview
Gulp overviewGulp overview
Gulp overview
 
Puppet camp london nov 2014 slides (1)
Puppet camp london nov 2014   slides (1)Puppet camp london nov 2014   slides (1)
Puppet camp london nov 2014 slides (1)
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdfHashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
 
Terraform-2.pdf
Terraform-2.pdfTerraform-2.pdf
Terraform-2.pdf
 
A quick start on Zend Framework 2
A quick start on Zend Framework 2A quick start on Zend Framework 2
A quick start on Zend Framework 2
 
Expressive Microservice Framework Blastoff
Expressive Microservice Framework BlastoffExpressive Microservice Framework Blastoff
Expressive Microservice Framework Blastoff
 
Zend expressive workshop
Zend expressive workshopZend expressive workshop
Zend expressive workshop
 
Zend Code in ZF 2.0
Zend Code in ZF 2.0Zend Code in ZF 2.0
Zend Code in ZF 2.0
 
Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
z13: New Opportunities – if you dare!
z13: New Opportunities – if you dare!z13: New Opportunities – if you dare!
z13: New Opportunities – if you dare!
 
ZF2: Writing Service Components
ZF2: Writing Service ComponentsZF2: Writing Service Components
ZF2: Writing Service Components
 
Deploying PHP apps on the cloud
Deploying PHP apps on the cloudDeploying PHP apps on the cloud
Deploying PHP apps on the cloud
 

Kürzlich hochgeladen

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Kürzlich hochgeladen (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Zend con practical-zf1-zf2-migration

  • 1. Practical ZF1 to ZF2 Migration: Lessons from the Field Clark Everetts, Zend Technologies, Inc.
  • 2. 2 What are we going to talk about? Getting from Here to Here Higher-Level (ROI, Organizational, Planning, Goals, Constraints) Lower-Level (Coding Suggestions, Tools, Resources, Best Practices) Suggestions / Best Practices
  • 3. 3 •Clark Everetts – Professional Services Consultant for Zend Technologies – Onsite and Remote Consulting – Linux, IBM iSeries, Windows ● Software Architecture Audits and Code Reviews ● Performance Audits ● Continuous Delivery Assessments – Online / Onsite Training in PHP, ZF, Studio, Server, etc. – SmartStarts: Training and Onsite Guided Development •Past Life: Independent Consultant (2002 - 2012) – Web Sites and Web Applications – Contract Instructor for Zend •Past, Past Life: Contractor for US Army and NASA (1990 - 2002) – Interceptor Ground Control Software; Green Screen Db Applications – Space Station: Real-time, Embedded Software; Science Platforms, Life Support Who am I?
  • 4. 4 •Your role: Manager, developer, stakeholder/decision-maker? •Size: Small to large companies; small to large dev teams •Have you migrated applications from ZF1 to ZF2? •Migrating now? How far along in the process are you? •What challenges did you face / are you facing? •What tools did you use, or wish existed? •What did you do before you started? •Did you expect to accomplish anything besides “the migration?” Who are You?
  • 5. What (I think) You Want to Know •Available Tools? How much do they do? •Low-hanging fruit; most difficulties? •Cost/Benefit? Expected gains? – Short-term? – Long-term? – When not to migrate? •How to plan a migration; what factors affect the planning? •Developer skills / skill levels required? •Budget, schedule is expected for a given project size? •Other resources?
  • 6. 6 •Zend's Collective Experience – Planning, Guiding, Implementing Migrations Where this talk comes from
  • 7. 7 The Prospect of Migration...
  • 8. 8 •Write new ZF2 application from scratch? •Run ZF1 and ZF2 side-by-side? – Use ZF2 components in existing ZF1 application – Use ZF1 components in new ZF2 application – Some URLs (existing capabilities) ZF1, with other URLs (entirely new features) implemented in ZF2 – Convert models, controllers, utility functions, helpers, etc. •Which ZF2 components are easiest to use in a ZF1 app? Decisions, decisions...
  • 9. More Decisions! •New URLs for new features of application: can do in ZF2, but will likely rely upon existing ZF1 models, helpers, etc., especially if you took the effort to make those components reusable in the first place •Build and test ZF2 version and then cut over from old site to new one, or iterate existing ZF1 production site into a new ZF2-based site? •Select a minimum PHP version – PHP 5.3.3 is minimum for ZF2; current are 5.5.4 and 5.4.20. PHP 5.3.27+ will receive only security fixes through much of 2014 (Zend supports PHP 5.2 for Enterprise customers on particular product versions; will continue to support PHP 5.3) – Consider most recent PHP version you can; this implies parallel migrations (PHP version as well as ZF2), Look at http://php.net/ChangeLog-5.php for removal of /changes to legacy features and new capabilities – Consider impact to other PHP apps on the server
  • 10. 10 No One Migration Strategy to Rule Them All There is no single, one-size-fits all, “correct” migration path for all applications and organizations. Many factors, including project size, team size and experience with ZF1 and ZF2, structure and quality of the ZF1 codebase, all affect the path to take. * http://ligh7bulb.deviantart.com/ *
  • 11. Remember the Planned Migration Layer? •Remember the planned Migration Layer? – Was to allow ZF1 code to run on the ZF2 “engine” – Work started during ZF2 betas; too much change between beta releases to keep such a tool current – Emulating ZF1 behaviour in ZF2 would have taken unacceptable amount of developer time away from ZF2 development •Though many people desired it, a full Migration Layer isn't strictly necessary – PHP 5.3 Namespaces – Migration: tedious, but not as hard as you think ● Depends on the code you're starting with! ● Fat controllers w/ data access, business logic, HTML :-(
  • 12. Some Tools Exist to Help •ZF2 Documentation Page http://framework.zend.com/manual/2.2/en/migration/overview.html ● GitHub: EvanDotPro/zf-2-for-1 ZF2 Form View Helpers, could be extended to other features • GitHib: prolic/HumusMvcSkeletonApplication integrates ModuleManager and ServiceManager into ZF1 application See http://www.sasaprolic.com/2012/10/when-migration-to-zend- framework-2.html
  • 13. 13 ZF1 Compatibility Module - Overview •Custom ZF2 Module that you write – simple, straightforward •Use existing ZF1-based application resources with minimal initial code rewrite: – Database – Translation – Session •That is, Any Zend_Application_Resource plugin •Obtain and use these resources as ZF2 Services via ServiceManager •Only for Application-wide, “global” resources
  • 14. 14 The Prospect of Migration... Starting to Feel Better?
  • 15. 15 •What you do depends on what you want – Delay a complete rewrite ● Phased approach, reusing much of your ZF1 code – Refactor and clean up “bad” code •Smaller Application, perhaps non mission-critical – Rewrite, use as a learning experience for a larger migration effort Planning
  • 16. 16 // config/application.config.php 'modules' => array( 'Application', 'Zf1', // <-- your ZF1 compatibility module // you will add other modules to the list as you progress ), // remainder of config array ZF1 Compatibility Module – Add Module to config
  • 17. 17 // module/Zf1/Module.php namespace Zf1; use ZendModuleManagerFeatureAutoloaderProviderInterface; use ZendMvcMvcEvent; class Module implements AutoloaderProviderInterface { public function getAutoloaderConfig() { $zf1path = getenv('ZF1_PATH'); // SetEnv in Apache vhost/.htaccess if (!$zf1path) { throw new Exception('Define ZF1 library path'); } /// more coming... ZF1 Compatibility Module – Autoload ZF1 Classes
  • 18. 18 // module/Zf1/Module.php getAutoloaderConfig() return array( 'ZendLoaderStandardAutoloader' => array ( 'namespaces' => array( __NAMESPACE__ => __DIR__ . '/src/' . str_replace('', '/', __NAMESPACE__) ), 'prefixes' => array('Zend' => $zf1path) ) ); ZF1 Compatibility Module – Autoload ZF1 (cont.)
  • 19. 19 // module/Zf1/config/module.config.php 'service_manager' => array ( 'factories' => array( 'zf1-db' => 'Zf1ServiceFactoryDatabase', 'zf1-translate'=> 'Zf1ServiceFactoryTranslate', // other ZF1-based resources... ), 'aliases' => array ( 'translate' => 'zf1-translate', ) ) ZF1 Compat. Module – Resources become Services
  • 20. 20 ZF1 Compat. Module – Factories to Create Services namespace Zf1ServiceFactory; use ZendServiceManager; class Database implements ServiceManagerFactoryInterface { public function createService( ServiceManagerServiceLocatorInterface $serviceLocator ) { $config = $serviceLocator->get('config'); $adapter = Zend_Db::factory( $config['zf1-db']['adapter'], $config['zf1-db']['params'] ); return $adapter; } }
  • 21. 21 ZF1 Compatibility Module – Register the Services // module/Zf1/Module.php public function onBootstrap(MvcEvent $e) { $services = $e->getApplication()->getServiceManager(); $dbAdapter = $services->get('zf1-db'); Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter); // Perhaps your views need config. For now, in views, access config // directly via registry. Later, use code that injects config into view $config = $services->get('config'); Zend_Registry::set('config', Util::arrayToObject($config)); // In audits, we often find ZF1 models accessing the db via registry // What you see here is not “best practice,” but a baby step toward // injecting this dependency in a later phase of migration $database = $services->get('zf1-db'); Zend_Registry::set('database', $database); $services = $e->getApplication()->getServiceManager(); Zend_Registry::set('session', $services->get('auth')->getStorage()- >read()); }
  • 22. 22 ZF1 Compatibility Module – Review •Temporary, stop-gap measure for reusing ZF1 resources •Avoids major up-front rewrite •Obtain and use these resources as ZF2 Services via ServiceManager: – Add it to the list of modules used by your ZF2 app – Set up autoloading to find ZF1 library – Identify Resources as Services to the ServiceManager – Write Factories to create the services – Register the Services •Only for Application-wide, “global” resources •Remember: This Module will GO AWAY in a later phase!
  • 23. 23 The Prospect of Migration... How are you feeling?
  • 24. 24 Reusing ZF1 Configuration - Overview •ZF1 Configuration – .ini, .xml, .json, .yaml •ZF2 Configuration – arrays •Reuse existing ZF1 configuration files in ZF2 application
  • 25. 25 Reusing ZF1 Configuration - .ini files // module/SomeModule/Module.php public function getConfig () { $path = __DIR__ . '/config/config.ini'; $config = new Zend_Config_Ini($path, $section); $oldConfig = $config->toArray(); if (defined('ZF1_COMPAT')) { $oldConfig['zf1-db'] = $oldConfig['db']; } // Fix 1: for the database options $dbParams = array ('driver' => $oldConfig['db']['adapter']); $dbParams = array_merge($dbParams, $oldConfig['db']['params']); $oldConfig['db'] = $dbParams; $phpConfig = include __DIR__ . '/config/module.config.php'; return array_merge($oldConfig, $phpConfig); }
  • 26. 26 Reuse ZF1 Models - Autoloading // module/SomeModule/Module.php public function getAutoloaderConfig () { return array( 'ZendLoaderClassMapAutoloader' => array( __DIR__ . '/autoload_classmap.php' ), 'ZendLoaderStandardAutoloader' => array ( 'namespaces' => array( // if we're in a namespace deeper than one level we need to // fix the in the path __NAMESPACE__ => __DIR__ . '/src/' . str_replace('', '/', __NAMESPACE__) ), 'prefixes' => array(// This goes away in later phase 'Model' => __DIR__ .'/src/' . str_replace('', '/', __NAMESPACE__) . '/Model', ) ) ); }
  • 27. 27 Reuse ZF1 Models – Merge config with ZF2 config // module/SomeModule/Module.php public function getConfig () { include __DIR__ . '/config/config.php'; $path = __DIR__ . '/config/config.ini'; $config = new Zend_Config_Ini($path, $section); $oldConfig = $config->toArray(); if (defined('ZF1_COMPAT')) { $oldConfig['zf1-db'] = $oldConfig['db']; } // database options from db section of config.ini $dbParams = array('driver' => $oldConfig['db']['adapter']); $dbParams = array_merge($dbParams, $oldConfig['db']['params']); $oldConfig['db'] = $dbParams; $phpConfig = include __DIR__ . '/config/module.config.php'; return array_merge($oldConfig, $phpConfig); } Opportunity for refactoring
  • 28. Thank You! Please give constructive feedback at https://joind.in/9083 Email: clark.e@zend.com https://github.com/clarkphp Twitter: @clarkphp