SlideShare uma empresa Scribd logo
1 de 30
Baixar para ler offline
Migration concepts for enterprise PHP applications
International PHP Conference 2008 – Spring Edition
Thorsten Rinne
Introduction

❙ Thorsten Rinne
❙ 31 years old
❙ Graduated in computer science
❙ Project manager at Mayflower GmbH, Munich
   ❙ Reporting applications
   ❙ Critical bank applications
   ❙ PHP Consulting
❙ PHP software development since 1999
❙ Founder and main developer of Open Source FAQ-
  management software phpMyFAQ since 2001
❙ Zend Certified Engineer (PHP 5)
                                                   „Migration concepts for enterprise
                                                   PHP applications“
                                                    © MAYFLOWER GmbH 2008 2
Summary

❙ Introduction
❙ Why upgrade?
❙ Process model
   ❙ MySQL upgrade process
   ❙ PHP upgrade process
❙ Migration
❙ Conclusion
❙ Questions and answers




                             „Migration concepts for enterprise
                             PHP applications“
                              © MAYFLOWER GmbH 2008 3
Introduction: Why upgrade?

❙ MySQL 4 support will end
   ❙ Active support already ended by the end of 2006
   ❙ Only extended support until 2008 for MySQL 4.0 and
     2009 for MySQL 4.1
   ❙ MySQL 5 has more and advanced features like stored
     procedures, trigger, better SQL support
❙ PHP 4 support will end
   ❙ PHP 4 is dead, dead, dead
   ❙ Only security relevant fixes until 2008-08-08
   ❙ PHP 5.2 is faster and more stable than every PHP 4
     version

                                                          „Migration concepts for enterprise
                                                          PHP applications“
                                                           © MAYFLOWER GmbH 2008 4
Introduction: Requirements

❙ No qualitative changes like new features
❙ No technical changes like
   ❙ new database layer
   ❙ new template engine
   ❙ Using new PHP 5 features
❙ No influences for productive services like
   ❙ External systems
   ❙ End user frontends
❙ Minimization of time and effort



                                               „Migration concepts for enterprise
                                               PHP applications“
                                                © MAYFLOWER GmbH 2008 5
Introduction: What is porting?
                                   Innovation potential
❙ Reasons
   ❙ Most simple form of
     migration




                                               ive
                                           sit
                                                                Rewrite
   ❙ Manageble risks




                                        po
   ❙ Small complexity because of
     the lack of qualitive and
                                               Reengineering
     technical changes




                                                                               e
                                                                            tiv
❙ Requirement




                                                                        ga
                                                                     ne
   ❙ Minor differences between
                                     Porting
     current and future
     application platform
                                                                                 complexity

                                                               „Migration concepts for enterprise
                                                               PHP applications“
                                                                © MAYFLOWER GmbH 2008 6
Process model

❙ Reducing of complexity with a planned procedure
❙ Coverage of the complete porting
❙ Methodical description of the process
❙ Tool support




                                                    „Migration concepts for enterprise
                                                    PHP applications“
                                                     © MAYFLOWER GmbH 2008 7
Process model: Preparations

❙ Targets
   ❙ Porting without any technical or qualitative changes
   ❙ Recovery of support (MySQL/PHP)
   ❙ Minimizing the interferences of services and reduction
     of change times
❙ Interferences
   ❙ Porting problems between MySQL and PHP versions
   ❙ Application complexity
   ❙ missing documentation and missing contact persons
   ❙ Communication between all team members


                                                              „Migration concepts for enterprise
                                                              PHP applications“
                                                               © MAYFLOWER GmbH 2008 8
Process modell: Upgrading MySQL

❙ Upgrade in two steps
   ❙ MySQL 4.0 to MySQL 4.1
   ❙ MySQL 4.1 to MySQL 5.0
❙ Why two steps?
   ❙ Big changes between 4.0 and 4.1
   ❙ Password changes
   ❙ Character sets
   ❙ Collations
   ❙ Many minor BC breaks




                                       „Migration concepts for enterprise
                                       PHP applications“
                                        © MAYFLOWER GmbH 2008 9
Upgrade path for MySQL

❙ First dump your current database, if it‘s InnoDB. If you use
  MyISAM, just backup everything.
❙ upgrade your development machine
❙ Reload your tables
❙ Test, test, test with MySQL 5.0
❙ Fix your queries and application if you have problems
❙ Use the STRICT MODE in MySQL 5.0
❙ Test, test, test with MySQL 5.0
❙ Upgrade your production machine
❙ Reload your production database


                                                                 „Migration concepts for enterprise
                                                                 PHP applications“
                                                                  © MAYFLOWER GmbH 2008 10
How to dump MySQL?

❙ Use the MySQL 4.1 mysqldump binary!
  shell> mysqldump –uroot -p
           –-database mydatabase
           --single-transaction
           --default-character-set=utf-8
           --disable-keys
           --extended-insert
           | bzip2 –c > backup.sql.bz2
  Warning: This can lock all tables!
❙ Fix the password column in the MySQL user table
  shell> mysql_fix_privilege_tables
            --password=root_password

                                                    „Migration concepts for enterprise
                                                    PHP applications“
                                                     © MAYFLOWER GmbH 2008 11
MySQL Pitfalls

❙ Rebuild your TIMESTAMPs, check this also in your application
❙ TIMESTAMP now has the format
  'YYYY-MM-DD HH:MM:SS'
❙ DECIMAL(14,2) in MySQL 4.0 is not the same as
  DECIMAL(14,2) in MySQL 4.1/5.0
   ❙ using DECIMAL(10,5): 100000 will be 99999.99999
   ❙ using DECIMAL(11,5): 100000 will be 100000.00000
❙ New reserved words
❙ SQL2003 standard for your SQL queries with natural JOINs
  and JOINs with USING may produce different results
❙ http://dev.mysql.com/doc/refman/5.0/en/upgrading-from-
  4-1.html
                                                           „Migration concepts for enterprise
                                                           PHP applications“
                                                            © MAYFLOWER GmbH 2008 12
After MySQL upgrade

❙ Release the current combination
❙ PHP 4 / MySQL 5
❙ Why?
   ❙ You never find all problems during your tests
   ❙ PHP porting may took longer than the MySQL porting
   ❙ Increase your experience with MySQL 5
❙ Prepare the PHP 5 update




                                                          „Migration concepts for enterprise
                                                          PHP applications“
                                                           © MAYFLOWER GmbH 2008 13
Process model: Upgrading PHP

❙ Which PHP version?
   ❙ Latest PHP 5.2 release for production, if you build by
     yourself or current PHP 5.2 package from your
     Linux/Unix/*BSD/Solaris distribution
   ❙ Testing with PHP 5.3-dev if you have time and money
❙ Please don‘t use
   ❙ PHP 5.0.x
   ❙ PHP 5.1.x
   ❙ PHP 6.0.0-dev




                                                              „Migration concepts for enterprise
                                                              PHP applications“
                                                               © MAYFLOWER GmbH 2008 14
Upgrade path for PHP

❙ upgrade your development machine to latest PHP 5.2
  release
❙ Test, test, test
❙ Fix your code if you have problems
    ❙ register_globals = off
    ❙ error_reporting = E_ALL & E_STRICT
    ❙ display_errors = on
    ❙ log_errors = on
❙ Test, test, test
❙ Upgrade your production machine
❙ Release your ported application
                                                       „Migration concepts for enterprise
                                                       PHP applications“
                                                        © MAYFLOWER GmbH 2008 15
Migrate configuration files

❙ httpd.conf
   ❙ change this line:
     LoadModule php4_module php/sapi/php4apache2.dll
   ❙ with this one:
     LoadModule php5_module /php/php5apache2.dll
❙ php.ini
   ❙ You should use the php.ini-recommended file, but check, if
     you need magic quotes on…. Otherwise your application could
     be insecure!




                                                        „Migration concepts for enterprise
                                                        PHP applications“
                                                         © MAYFLOWER GmbH 2008 16
PHP 5 Pitfalls:
New reserved keyords

❙ abstract             ❙ public
❙ catch                ❙ throw
❙ clone                ❙ try
❙ extends              ❙ use
❙ final                ❙ namespace
❙ implements
❙ instanceof
❙ interface
❙ goto
❙ private
❙ protected
                                     „Migration concepts for enterprise
                                     PHP applications“
                                      © MAYFLOWER GmbH 2008 17
PHP 5 Pitfalls
Constructor / Destructor

❙ PHP 4
   ❙ construct method has the name of the class
   ❙ No destruct method
❙ PHP 5
   ❙ construct method: __construct()
      ❙ If not available, fallback to PHP4 handling
   ❙ destruct method: __destruct()
      ❙ Executed at the end of the request




                                                      „Migration concepts for enterprise
                                                      PHP applications“
                                                       © MAYFLOWER GmbH 2008 18
PHP 5 Pitfalls
Magic methods

❙ __autoload()
❙ __call(), __callStatic() (only PHP 5.3)
❙ __construct()
❙ __destruct()
❙ __get()
❙ __isset()
❙ __set()
❙ __set_state()
❙ __sleep()
❙ __toString()
❙ __unset()
❙ __wakeup()                                „Migration concepts for enterprise
                                            PHP applications“
                                             © MAYFLOWER GmbH 2008 19
PHP 5 Pitfalls

❙ get_class(), get_parent_class() and
  get_class_methods() now case-sensitive
❙ __CLASS__, __METHOD__, and __FUNCTION__ are also
  case-sensitive
❙ Objects are referenced by handle, and not by value
❙ Objects aren’t primitive types like in PHP 4
❙ If you need a copy of a object, use __clone()
❙ Re-declaration of $this isn’t allowed anymore
❙ === operator is more strict than it was in PHP 4
❙ __call()/__set()/__get() are different in PHP 4
❙ Don’t use zend.ze1.compatibility_mode!
❙ Use instanceof instead of is_a()                     „Migration concepts for enterprise
                                                       PHP applications“
                                                        © MAYFLOWER GmbH 2008 20
Migration strategies

❙ After the release of the PHP 5 ported application
  REFACTORING!
❙ Strategies for
   ❙ „Spaghetti code“
   ❙ Half procedural – half object-orientated
   ❙ PHP 4 OOP
❙ Please don‘t try a complete rewrite
   ❙ Too expensive
   ❙ Takes too long
   ❙ Joel on software: „Things You Should Never Do “


                                                       „Migration concepts for enterprise
                                                       PHP applications“
                                                        © MAYFLOWER GmbH 2008 21
Migration
„Spaghetti Code“

❙ Very old code, maybe developed in the last PHP 3 century
❙ No or just minor separation of code and layout
❙ No use of libraries like PEAR, Zend Framework or eZ
  components
❙ No documentation
❙ No tests




                                                             „Migration concepts for enterprise
                                                             PHP applications“
                                                              © MAYFLOWER GmbH 2008 22
Migration
„Spaghetti Code“: Strategy

❙ Identify recurring code parts and implement classes
❙ Use of standard libraries like Zend Framework, eZ
  components or PEAR
❙ Add inline documentation
❙ Fix your coding styles
❙ Add unittests for the new, refactored backend
❙ Add Selenium tests for the frontend




                                                        „Migration concepts for enterprise
                                                        PHP applications“
                                                         © MAYFLOWER GmbH 2008 23
Migration
„Half procedual – halb object-orientated“

❙ Code with differend quality
❙ Just a few documentation
❙ Maybe some tests
❙ „the typical current PHP 4 project“ ☺




                                            „Migration concepts for enterprise
                                            PHP applications“
                                             © MAYFLOWER GmbH 2008 24
Migration
„ Half procedual – halb object-orientated“: Strategy

❙ Add inline documentation for all classes and methods
❙ Improve the re-using of duplicate code
❙ Add unittests and Selenium tests
❙ Improve every code part with PHP 5 functions, for example
  using file_put_contents() instead of fopen(),
  fwrite(), and fclose().




                                                              „Migration concepts for enterprise
                                                              PHP applications“
                                                               © MAYFLOWER GmbH 2008 25
Migration
PHP 4 OOP

❙ Application was developed object-orientated in PHP 4
❙ Using of
   ❙ PHP 4 references
   ❙ Re-declaration of $this




                                                         „Migration concepts for enterprise
                                                         PHP applications“
                                                          © MAYFLOWER GmbH 2008 26
Migration
PHP 4 OOP: Strategy

❙ Maybe you‘re lucky and there are no problems. Maybe.
❙ If you see problems, they are fatal errors like
   ❙ Objects are referenced by value
   ❙ $foo =& new Foo();
❙ Solution:
   ❙ Implement unittests
   ❙ Use standard APIs
   ❙ Fix the PHP 5 problems




                                                         „Migration concepts for enterprise
                                                         PHP applications“
                                                          © MAYFLOWER GmbH 2008 27
Conclusion

❙ Migration is always possible
❙ Migration can be hard, but usually it isn‘t! ☺
❙ Don‘t shoot yourself in the foot with the migration
   ❙ First upgrade MySQL
   ❙ Then upgrade PHP and fix your application
   ❙ Then do the cleanup for a better future ☺
   ❙ Stay current in the future and do always small steps
   ❙ Keep PHP 5.3 and PHP 5.4 in mind!




                                                            „Migration concepts for enterprise
                                                            PHP applications“
                                                             © MAYFLOWER GmbH 2008 28
Questions and answers




                        „Migration concepts for enterprise
                        PHP applications“
                         © MAYFLOWER GmbH 2008 29
Thank you very much!

Thorsten Rinne, Dipl.-Inf. (FH)
Mayflower GmbH
Mannhardtstraße 6
D-80538 München
Germany
+49 (89) 24 20 54 – 31
thorsten.rinne@mayflower.de

Mais conteúdo relacionado

Semelhante a Migration Concepts For Enterprise PHP Applications

Quality In PHP Projects Beyond Unittests
Quality In PHP Projects Beyond UnittestsQuality In PHP Projects Beyond Unittests
Quality In PHP Projects Beyond Unittests
Mayflower GmbH
 
Quality in PHP projects beyond Unittests.pdf
Quality in PHP projects beyond Unittests.pdfQuality in PHP projects beyond Unittests.pdf
Quality in PHP projects beyond Unittests.pdf
guestf62d67
 
PHP in the Enterprise … connecting to SAP
PHP in the Enterprise … connecting to SAPPHP in the Enterprise … connecting to SAP
PHP in the Enterprise … connecting to SAP
webhostingguy
 
Stateful SOAP Webservices
Stateful SOAP WebservicesStateful SOAP Webservices
Stateful SOAP Webservices
Mayflower GmbH
 

Semelhante a Migration Concepts For Enterprise PHP Applications (20)

Exploitez le meilleur de SAP avec EMC
Exploitez le meilleur de SAP avec EMCExploitez le meilleur de SAP avec EMC
Exploitez le meilleur de SAP avec EMC
 
Quality In PHP Projects Beyond Unittests
Quality In PHP Projects Beyond UnittestsQuality In PHP Projects Beyond Unittests
Quality In PHP Projects Beyond Unittests
 
Quality in PHP projects beyond Unittests.pdf
Quality in PHP projects beyond Unittests.pdfQuality in PHP projects beyond Unittests.pdf
Quality in PHP projects beyond Unittests.pdf
 
Avantage Enterprise Architecture
Avantage Enterprise ArchitectureAvantage Enterprise Architecture
Avantage Enterprise Architecture
 
MySQL Aquarium Paris
MySQL Aquarium ParisMySQL Aquarium Paris
MySQL Aquarium Paris
 
XS Japan 2008 Oracle VM English
XS Japan 2008 Oracle VM EnglishXS Japan 2008 Oracle VM English
XS Japan 2008 Oracle VM English
 
VMware vSphere 4.0: The best platform for business applications
VMware vSphere 4.0: The best platform for business applicationsVMware vSphere 4.0: The best platform for business applications
VMware vSphere 4.0: The best platform for business applications
 
Avantage BPM Key Features
Avantage BPM Key FeaturesAvantage BPM Key Features
Avantage BPM Key Features
 
PHP in the Enterprise … connecting to SAP
PHP in the Enterprise … connecting to SAPPHP in the Enterprise … connecting to SAP
PHP in the Enterprise … connecting to SAP
 
L'Iperconvergenza 2.0: NetApp HCI in Action
L'Iperconvergenza 2.0: NetApp HCI in ActionL'Iperconvergenza 2.0: NetApp HCI in Action
L'Iperconvergenza 2.0: NetApp HCI in Action
 
Innovation and Change At the Speed of Your BusinessExecutive SummitVilla d´Este
Innovation and Change At the Speed of Your BusinessExecutive SummitVilla d´EsteInnovation and Change At the Speed of Your BusinessExecutive SummitVilla d´Este
Innovation and Change At the Speed of Your BusinessExecutive SummitVilla d´Este
 
Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2
 
Emc solutions for sap_overview
Emc solutions for sap_overviewEmc solutions for sap_overview
Emc solutions for sap_overview
 
Bugtracking 101 Macq Electronique 2010
Bugtracking 101  Macq Electronique 2010Bugtracking 101  Macq Electronique 2010
Bugtracking 101 Macq Electronique 2010
 
Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)Enterprise PHP (php|works 2008)
Enterprise PHP (php|works 2008)
 
Stateful SOAP Webservices
Stateful SOAP WebservicesStateful SOAP Webservices
Stateful SOAP Webservices
 
Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008
 
DevOps at EMC NYC August 2015 - Modernize your apps to drive organizational e...
DevOps at EMC NYC August 2015 - Modernize your apps to drive organizational e...DevOps at EMC NYC August 2015 - Modernize your apps to drive organizational e...
DevOps at EMC NYC August 2015 - Modernize your apps to drive organizational e...
 
Linux Everywhere? Matching the Workload to the Computer
Linux Everywhere? Matching the Workload to the ComputerLinux Everywhere? Matching the Workload to the Computer
Linux Everywhere? Matching the Workload to the Computer
 
Zend Framework Getting Started For I5
Zend Framework Getting Started For I5Zend Framework Getting Started For I5
Zend Framework Getting Started For I5
 

Mais de Mayflower GmbH

Plugging holes — javascript memory leak debugging
Plugging holes — javascript memory leak debuggingPlugging holes — javascript memory leak debugging
Plugging holes — javascript memory leak debugging
Mayflower GmbH
 

Mais de Mayflower GmbH (20)

Mit Maintenance umgehen können- Fixt du noch Bugs oder lieferst du schon neue...
Mit Maintenance umgehen können- Fixt du noch Bugs oder lieferst du schon neue...Mit Maintenance umgehen können- Fixt du noch Bugs oder lieferst du schon neue...
Mit Maintenance umgehen können- Fixt du noch Bugs oder lieferst du schon neue...
 
Why and what is go
Why and what is goWhy and what is go
Why and what is go
 
Agile Anti-Patterns
Agile Anti-PatternsAgile Anti-Patterns
Agile Anti-Patterns
 
JavaScript Days 2015: Security
JavaScript Days 2015: SecurityJavaScript Days 2015: Security
JavaScript Days 2015: Security
 
Vom Entwickler zur Führungskraft
Vom Entwickler zur FührungskraftVom Entwickler zur Führungskraft
Vom Entwickler zur Führungskraft
 
Produktive teams
Produktive teamsProduktive teams
Produktive teams
 
Salt and pepper — native code in the browser Browser using Google native Client
Salt and pepper — native code in the browser Browser using Google native ClientSalt and pepper — native code in the browser Browser using Google native Client
Salt and pepper — native code in the browser Browser using Google native Client
 
Plugging holes — javascript memory leak debugging
Plugging holes — javascript memory leak debuggingPlugging holes — javascript memory leak debugging
Plugging holes — javascript memory leak debugging
 
Usability im web
Usability im webUsability im web
Usability im web
 
Rewrites überleben
Rewrites überlebenRewrites überleben
Rewrites überleben
 
JavaScript Security
JavaScript SecurityJavaScript Security
JavaScript Security
 
50 mal produktiver - oder warum ich gute Teams brauche und nicht gute Entwick...
50 mal produktiver - oder warum ich gute Teams brauche und nicht gute Entwick...50 mal produktiver - oder warum ich gute Teams brauche und nicht gute Entwick...
50 mal produktiver - oder warum ich gute Teams brauche und nicht gute Entwick...
 
Responsive Webdesign
Responsive WebdesignResponsive Webdesign
Responsive Webdesign
 
Native Cross-Platform-Apps mit Titanium Mobile und Alloy
Native Cross-Platform-Apps mit Titanium Mobile und AlloyNative Cross-Platform-Apps mit Titanium Mobile und Alloy
Native Cross-Platform-Apps mit Titanium Mobile und Alloy
 
Pair Programming Mythbusters
Pair Programming MythbustersPair Programming Mythbusters
Pair Programming Mythbusters
 
Shoeism - Frau im Glück
Shoeism - Frau im GlückShoeism - Frau im Glück
Shoeism - Frau im Glück
 
Bessere Software schneller liefern
Bessere Software schneller liefernBessere Software schneller liefern
Bessere Software schneller liefern
 
Von 0 auf 100 in 2 Sprints
Von 0 auf 100 in 2 SprintsVon 0 auf 100 in 2 Sprints
Von 0 auf 100 in 2 Sprints
 
Piwik anpassen und skalieren
Piwik anpassen und skalierenPiwik anpassen und skalieren
Piwik anpassen und skalieren
 
Agilitaet im E-Commerce - E-Commerce Breakfast
Agilitaet im E-Commerce - E-Commerce BreakfastAgilitaet im E-Commerce - E-Commerce Breakfast
Agilitaet im E-Commerce - E-Commerce Breakfast
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 

Migration Concepts For Enterprise PHP Applications

  • 1. Migration concepts for enterprise PHP applications International PHP Conference 2008 – Spring Edition Thorsten Rinne
  • 2. Introduction ❙ Thorsten Rinne ❙ 31 years old ❙ Graduated in computer science ❙ Project manager at Mayflower GmbH, Munich ❙ Reporting applications ❙ Critical bank applications ❙ PHP Consulting ❙ PHP software development since 1999 ❙ Founder and main developer of Open Source FAQ- management software phpMyFAQ since 2001 ❙ Zend Certified Engineer (PHP 5) „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 2
  • 3. Summary ❙ Introduction ❙ Why upgrade? ❙ Process model ❙ MySQL upgrade process ❙ PHP upgrade process ❙ Migration ❙ Conclusion ❙ Questions and answers „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 3
  • 4. Introduction: Why upgrade? ❙ MySQL 4 support will end ❙ Active support already ended by the end of 2006 ❙ Only extended support until 2008 for MySQL 4.0 and 2009 for MySQL 4.1 ❙ MySQL 5 has more and advanced features like stored procedures, trigger, better SQL support ❙ PHP 4 support will end ❙ PHP 4 is dead, dead, dead ❙ Only security relevant fixes until 2008-08-08 ❙ PHP 5.2 is faster and more stable than every PHP 4 version „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 4
  • 5. Introduction: Requirements ❙ No qualitative changes like new features ❙ No technical changes like ❙ new database layer ❙ new template engine ❙ Using new PHP 5 features ❙ No influences for productive services like ❙ External systems ❙ End user frontends ❙ Minimization of time and effort „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 5
  • 6. Introduction: What is porting? Innovation potential ❙ Reasons ❙ Most simple form of migration ive sit Rewrite ❙ Manageble risks po ❙ Small complexity because of the lack of qualitive and Reengineering technical changes e tiv ❙ Requirement ga ne ❙ Minor differences between Porting current and future application platform complexity „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 6
  • 7. Process model ❙ Reducing of complexity with a planned procedure ❙ Coverage of the complete porting ❙ Methodical description of the process ❙ Tool support „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 7
  • 8. Process model: Preparations ❙ Targets ❙ Porting without any technical or qualitative changes ❙ Recovery of support (MySQL/PHP) ❙ Minimizing the interferences of services and reduction of change times ❙ Interferences ❙ Porting problems between MySQL and PHP versions ❙ Application complexity ❙ missing documentation and missing contact persons ❙ Communication between all team members „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 8
  • 9. Process modell: Upgrading MySQL ❙ Upgrade in two steps ❙ MySQL 4.0 to MySQL 4.1 ❙ MySQL 4.1 to MySQL 5.0 ❙ Why two steps? ❙ Big changes between 4.0 and 4.1 ❙ Password changes ❙ Character sets ❙ Collations ❙ Many minor BC breaks „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 9
  • 10. Upgrade path for MySQL ❙ First dump your current database, if it‘s InnoDB. If you use MyISAM, just backup everything. ❙ upgrade your development machine ❙ Reload your tables ❙ Test, test, test with MySQL 5.0 ❙ Fix your queries and application if you have problems ❙ Use the STRICT MODE in MySQL 5.0 ❙ Test, test, test with MySQL 5.0 ❙ Upgrade your production machine ❙ Reload your production database „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 10
  • 11. How to dump MySQL? ❙ Use the MySQL 4.1 mysqldump binary! shell> mysqldump –uroot -p –-database mydatabase --single-transaction --default-character-set=utf-8 --disable-keys --extended-insert | bzip2 –c > backup.sql.bz2 Warning: This can lock all tables! ❙ Fix the password column in the MySQL user table shell> mysql_fix_privilege_tables --password=root_password „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 11
  • 12. MySQL Pitfalls ❙ Rebuild your TIMESTAMPs, check this also in your application ❙ TIMESTAMP now has the format 'YYYY-MM-DD HH:MM:SS' ❙ DECIMAL(14,2) in MySQL 4.0 is not the same as DECIMAL(14,2) in MySQL 4.1/5.0 ❙ using DECIMAL(10,5): 100000 will be 99999.99999 ❙ using DECIMAL(11,5): 100000 will be 100000.00000 ❙ New reserved words ❙ SQL2003 standard for your SQL queries with natural JOINs and JOINs with USING may produce different results ❙ http://dev.mysql.com/doc/refman/5.0/en/upgrading-from- 4-1.html „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 12
  • 13. After MySQL upgrade ❙ Release the current combination ❙ PHP 4 / MySQL 5 ❙ Why? ❙ You never find all problems during your tests ❙ PHP porting may took longer than the MySQL porting ❙ Increase your experience with MySQL 5 ❙ Prepare the PHP 5 update „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 13
  • 14. Process model: Upgrading PHP ❙ Which PHP version? ❙ Latest PHP 5.2 release for production, if you build by yourself or current PHP 5.2 package from your Linux/Unix/*BSD/Solaris distribution ❙ Testing with PHP 5.3-dev if you have time and money ❙ Please don‘t use ❙ PHP 5.0.x ❙ PHP 5.1.x ❙ PHP 6.0.0-dev „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 14
  • 15. Upgrade path for PHP ❙ upgrade your development machine to latest PHP 5.2 release ❙ Test, test, test ❙ Fix your code if you have problems ❙ register_globals = off ❙ error_reporting = E_ALL & E_STRICT ❙ display_errors = on ❙ log_errors = on ❙ Test, test, test ❙ Upgrade your production machine ❙ Release your ported application „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 15
  • 16. Migrate configuration files ❙ httpd.conf ❙ change this line: LoadModule php4_module php/sapi/php4apache2.dll ❙ with this one: LoadModule php5_module /php/php5apache2.dll ❙ php.ini ❙ You should use the php.ini-recommended file, but check, if you need magic quotes on…. Otherwise your application could be insecure! „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 16
  • 17. PHP 5 Pitfalls: New reserved keyords ❙ abstract ❙ public ❙ catch ❙ throw ❙ clone ❙ try ❙ extends ❙ use ❙ final ❙ namespace ❙ implements ❙ instanceof ❙ interface ❙ goto ❙ private ❙ protected „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 17
  • 18. PHP 5 Pitfalls Constructor / Destructor ❙ PHP 4 ❙ construct method has the name of the class ❙ No destruct method ❙ PHP 5 ❙ construct method: __construct() ❙ If not available, fallback to PHP4 handling ❙ destruct method: __destruct() ❙ Executed at the end of the request „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 18
  • 19. PHP 5 Pitfalls Magic methods ❙ __autoload() ❙ __call(), __callStatic() (only PHP 5.3) ❙ __construct() ❙ __destruct() ❙ __get() ❙ __isset() ❙ __set() ❙ __set_state() ❙ __sleep() ❙ __toString() ❙ __unset() ❙ __wakeup() „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 19
  • 20. PHP 5 Pitfalls ❙ get_class(), get_parent_class() and get_class_methods() now case-sensitive ❙ __CLASS__, __METHOD__, and __FUNCTION__ are also case-sensitive ❙ Objects are referenced by handle, and not by value ❙ Objects aren’t primitive types like in PHP 4 ❙ If you need a copy of a object, use __clone() ❙ Re-declaration of $this isn’t allowed anymore ❙ === operator is more strict than it was in PHP 4 ❙ __call()/__set()/__get() are different in PHP 4 ❙ Don’t use zend.ze1.compatibility_mode! ❙ Use instanceof instead of is_a() „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 20
  • 21. Migration strategies ❙ After the release of the PHP 5 ported application REFACTORING! ❙ Strategies for ❙ „Spaghetti code“ ❙ Half procedural – half object-orientated ❙ PHP 4 OOP ❙ Please don‘t try a complete rewrite ❙ Too expensive ❙ Takes too long ❙ Joel on software: „Things You Should Never Do “ „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 21
  • 22. Migration „Spaghetti Code“ ❙ Very old code, maybe developed in the last PHP 3 century ❙ No or just minor separation of code and layout ❙ No use of libraries like PEAR, Zend Framework or eZ components ❙ No documentation ❙ No tests „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 22
  • 23. Migration „Spaghetti Code“: Strategy ❙ Identify recurring code parts and implement classes ❙ Use of standard libraries like Zend Framework, eZ components or PEAR ❙ Add inline documentation ❙ Fix your coding styles ❙ Add unittests for the new, refactored backend ❙ Add Selenium tests for the frontend „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 23
  • 24. Migration „Half procedual – halb object-orientated“ ❙ Code with differend quality ❙ Just a few documentation ❙ Maybe some tests ❙ „the typical current PHP 4 project“ ☺ „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 24
  • 25. Migration „ Half procedual – halb object-orientated“: Strategy ❙ Add inline documentation for all classes and methods ❙ Improve the re-using of duplicate code ❙ Add unittests and Selenium tests ❙ Improve every code part with PHP 5 functions, for example using file_put_contents() instead of fopen(), fwrite(), and fclose(). „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 25
  • 26. Migration PHP 4 OOP ❙ Application was developed object-orientated in PHP 4 ❙ Using of ❙ PHP 4 references ❙ Re-declaration of $this „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 26
  • 27. Migration PHP 4 OOP: Strategy ❙ Maybe you‘re lucky and there are no problems. Maybe. ❙ If you see problems, they are fatal errors like ❙ Objects are referenced by value ❙ $foo =& new Foo(); ❙ Solution: ❙ Implement unittests ❙ Use standard APIs ❙ Fix the PHP 5 problems „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 27
  • 28. Conclusion ❙ Migration is always possible ❙ Migration can be hard, but usually it isn‘t! ☺ ❙ Don‘t shoot yourself in the foot with the migration ❙ First upgrade MySQL ❙ Then upgrade PHP and fix your application ❙ Then do the cleanup for a better future ☺ ❙ Stay current in the future and do always small steps ❙ Keep PHP 5.3 and PHP 5.4 in mind! „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 28
  • 29. Questions and answers „Migration concepts for enterprise PHP applications“ © MAYFLOWER GmbH 2008 29
  • 30. Thank you very much! Thorsten Rinne, Dipl.-Inf. (FH) Mayflower GmbH Mannhardtstraße 6 D-80538 München Germany +49 (89) 24 20 54 – 31 thorsten.rinne@mayflower.de