SlideShare a Scribd company logo
1 of 58
Modernisation of legacy PHP applications
                                        using Symfony2




                      19/03/2013   1   THEODO
The need for progressive rewrite

The technical challenges and our solutions

The future




                            19/03/2013   2   THEODO
Legacy PHP applications are everywhere
    History of PHP applications


•   79% : websites written in PHP among the top 1 million, according
    to W3Techs.com

•   1994: PHP was created

•   2004: PHP5 was released. Start of OOP

•   2007: ZF 1.0.0 and SF 1.0 were released. Start of the MVC age

               13 years of (mostly) spagetthi-coded web-apps



                                           19/03/2013   3   THEODO
What is the problem of legacy applications?
The need for rewrite




                                 19/03/2013   4   THEODO
Starting a new version from scratch is a danger to the business
    The dangers of total rewrite




•   New developments are invisible until the new version is finished

•   You need twice more developers: one team to maintain the old
    application, while the second team is writing the new version

•   The probability of forgetting features during the rewrite is high

•   Transition when the new version is ready becomes costly and
    very dangerous: everything is impacted at once



                                           19/03/2013   5   THEODO
More dangerous than you think!
      The black swan blindness


A study led by two Oxford professors on 1,471 IT projects found out that:
• 1 project out of 6 ended up costing on average 3 times as much!
• large-scale computer spending were 20 times more likely to spiral out
   of control than expected.

 Large-scale examples:
 •   the complete revamp of Levi Strauss’ IT, which
     cost them 192.5 million$ losses
 •   FoxMeyer Drugs’ bankruptcy after switching
     brutally to SAP

Study: http://users.ox.ac.uk/~mast2876/WP_2011_08_15.pdf
Fox-Meyer bankruptcy: http://fr.slideshare.net/jmramireza/the-foxmeyer-drugs-bankruptcy-was-it-a-failure-
of-erp-2332065
                                                           19/03/2013   6   THEODO
Progressive rewrite is the solution… but is very challenging
    The challenge of progressive rewrite




•   You have to work with hard-to-read code

•   All the aspects of an application in production are concerned:
      source code of course
      system
      data
      cache
      remote webservices, etc.

•   The major conceptual challenge in all those aspects is decoupling
    of modules. Just like in scaling!

                                           19/03/2013   7   THEODO
Progressive rewrite is more profitable
                      Unbeatable time-to-market
Functionalities




                                                       Functionalities
                                                                                                   Evolution




                                   Time                                                       Time


                  •   No new features for months   •                Only 1 app to maintain
                  •   2 apps to maintain           •                Lower regression risks
                                                   •                Unbeatable time-to-market


                                                                         19/03/2013   8   THEODO
The need for progressive rewrite

The technical challenges and our solutions

The future




                            19/03/2013   9   THEODO
Theodo Evolution
    Our solution at Theodo




•   R&D project started at Theodo in 2012

•   Aims to solve all these issues to make app rewriting agile again

•   Our dream: be able to code evolutions on the legacy application
    without touching the legacy code.




                                          19/03/2013   10   THEODO
The technical experts behind Theodo Evolution
Theodo Evolution team




                                19/03/2013   11   THEODO
The big picture of the different technical aspects to solve
    The technical challenges




•   Preventing regressions
•   Upgrading the system
•   Routing
•   Sharing the layout
•   Sharing the session/authentication
•   Decoupling the code
•   Migrating the model and data




                                         19/03/2013   12   THEODO
Preventing regressions




 19/03/2013   13   THEODO
Belt and straps are necessary… and won’t be enough…
Preventing regressions




                               19/03/2013   14   THEODO
Functionally test what could harm your business
    Preventing regressions




•   By definition, spaghetti code is deeply coupled. Touching one part
    breaks something at the other end

•   Create functional tests on the most critical scenarios

•   Mink + ZombieJS: https://github.com/Behat/Mink




                                           19/03/2013   15   THEODO
Setup good monitoring
    Preventing regressions


The most thorough functional testing is done... by putting in production!

•   Monitor production well.
    • Errors 500, 404
    • response time with Pingdom
    • newrelic
•   Make everybody aware of the heightened risks

•   Monitor business metrics with StatsD, give the marketing team a
    Graphite dashboard => get free high-level monitoring!

                                         19/03/2013   16   THEODO
And create a fast and easy deployment pipeline
    Preventing regressions




•   Deploy often and small updates. Aim ten a day, not just one a week!

•   Setup a fast rollback system

•   Setup a fast deployment system, because you want to make it faster
    to correct small problems than to rollback




                                         19/03/2013   17   THEODO
Simple automated deployment with Fabric
       Automated deployment




@roles('prod')
def deploy():
  tag = "%s/%s" % (_getrole(), strftime("%Y/%m-%d-%H-%M-%S"))
  local('git tag -a %s -m "%s"' % (tag, _getrole()))
  local('git push --tags')

  run('git fetch’)
  run('git fetch origin --tags')
  tag = run('git tag -l %s/* | sort | tail -n1' % _getrole())
  run('git checkout ' + tag)
  run('php composer.phar install')




                                                      19/03/2013   18   THEODO
Upgrading the system




19/03/2013   19   THEODO
Migrate to a modern environment that supports Symfony2
    …and improves performance as a bonus.
    Upgrading the system




•   Symfony2 requires:
     • PHP 5.3.3
     • Sqlite3, JSON, ctype
     • date.timezone set in php.ini
•   php app/check.php




                                      19/03/2013   20   THEODO
Check that the legacy code will support PHP 5.3/5.4
    Upgrading the system




•   Phpcs CodeSniffs for 5.3 and 5.4 compatibility:
    https://github.com/wimg/PHPCompatibility

•   Setup a pre-production environment in the upgraded
    environment and run your functional tests on it

•   And this time provision your environment with Puppet or Chef!
    Check Blueprint: https://github.com/devstructure/blueprint




                                          19/03/2013   21   THEODO
Routing




19/03/2013   22   THEODO
Routing between the old and the new
    Routing


•   The beauty of PHP: some legacy apps have simply no routing system!

•   Host the new app next to the old app, with clear URL differences, and
    proxy at the server level
     • Subdomain: v2.myapp.com
     • Subfolder: www.myapp.com/v2/
•   My favourite: create a catchall route with Symfony2




                                         19/03/2013   23   THEODO
The CatchAll Route
Routing



    class LegacyController extends Controller
    {
      /**
       * @Route("/{filename}.php", name="_proxy")
       */
      public function proxyAction($filename)
      {
          ob_start();
          include $filename . '.php';

              // Replace exit()s and die()s
              // or you might never end up here
              return new Response(ob_get_clean());
          }
    }


                                            19/03/2013   24   THEODO
Sharing the layout




19/03/2013   25   THEODO
For end-users « progressive rewrite » = « same template »
      Sharing the layout




•     Copy-pasting the layout is not a good solution

•     Our solution : crawl the legacy layout and include it as ESIs



    <esi:include src="{{ path('legacylayout_top') }}" />

    {% block body %}{% endblock %}

    <esi:include src="{{ path('legacylayout_bottom') }}" />




                                                  19/03/2013   26   THEODO
The « crawling » part of the ESI sub-request
    Sharing the layout



$this->client->setHeader('Cookie', $currentCookie);

if ($request->headers->has('authorization')) {
    $this->client->setHeader(
       'Authorization',
       $request->headers->get('authorization')
    );
}

if ($this->session->isStarted()) {
    $this->session->save();
}

$this->client->request('GET', $url);
$esiContent = $this->client->getResponse()->getContent();


                                                 19/03/2013   27   THEODO
Sharing the session/authentication




             19/03/2013   28   THEODO
Make the legacy session accessible from Symfony2
    Sharing the session/authentication




•   You want to access what your legacy app has put in the session
    from within Symfony2…

•   BUT Symfony2 expects session information to be neatly stored in
    arrays in the « _sf2_attributes » namespace

          to make your legacy session accessible, you need to :
    •   register « Bags » for each of your legacy $_SESSION keys
    •   create a « ScalarBag » type when these values are not arrays



                                          19/03/2013   29   THEODO
Example for a Symfony1 Session
 Sharing the session/authentication




// onKernelRequest
foreach ( array('symfony/user/sfUser/credentials',
          'symfony/user/sfUser/attributes’) as $namespace) {
    $bag = new NamespacedAttributeBag($namespace, '.');
    $bag->setName($namespace);
    $session->registerBag($bag);
}




                                           19/03/2013   30   THEODO
Decoupling the code




19/03/2013   31   THEODO
Attacking the spaghetti problem
Decoupling the code




                                  19/03/2013   32   THEODO
Decoupling is a major aspect of progressive rewrite
Decoupling the code




                                 19/03/2013   33   THEODO
Decoupling is a major aspect of progressive rewrite
Decoupling the code




                                 19/03/2013   34   THEODO
Decoupling is a major aspect of progressive rewrite
Decoupling the code




                                 19/03/2013   35   THEODO
Decoupling is a major aspect of progressive rewrite
Decoupling the code




                                 19/03/2013   36   THEODO
Decoupling is a major aspect of progressive rewrite
Decoupling the code




                                 19/03/2013   37   THEODO
Decoupling is a major aspect of progressive rewrite
Decoupling the code




                                 19/03/2013   38   THEODO
The dream architecture
Decoupling the code




                         19/03/2013   39   THEODO
What you usually find
Decoupling the code




                        19/03/2013   40   THEODO
You need to create the dream API and slowly refactor around it
Decoupling the code
                               A
           A                   P
           P                   I
                                                                  A
           I                                                      P
                                                                  I
                                   A
                                   P
                                   I
                      A
                      P
                      I                                  A
                           A
                                                         P
                           P
                                                         I
                           I




                                       19/03/2013   41   THEODO
You need to create the dream API and slowly refactor around it
Decoupling the code
                               A
           A                   P
           P                   I
                                                                  A
           I                                                      P
                                                                  I
                                   A
                                   P
                                   I
                      A
                      P
                      I                                  A
                           A
                                                         P
                           P
                                                         I
                           I




                                       19/03/2013   42   THEODO
You need to create the dream API and slowly refactor around it
Decoupling the code
                               A
           A                   P
           P                   I
                                                                  A
           I                                                      P
                                                                  I
                                   A
                                   P
                                   I
                      A
                      P
                      I                                  A
                           A
                                                         P
                           P
                                                         I
                           I




                                       19/03/2013   43   THEODO
You need to create the dream API and slowly refactor around it
Decoupling the code
                               A
           A                   P
           P                   I
                                                                  A
           I                                                      P
                                                                  I
                                   A
                                   P
                                   I
                      A
                      P
                      I                                  A
                           A
                                                         P
                           P
                                                         I
                           I




                                       19/03/2013   44   THEODO
This is called « Facade Pattern »
   Decoupling the code


Wikipedia
A facade is an object that provides a simplified interface to a larger
body of code, such as a class library.
[…]
A façade reduces dependencies of outside code on the inner
workings of a library, since most code uses the facade, thus allowing
more flexibility in developing the system;




                                          19/03/2013   45   THEODO
Symfony2 Service Container
    Decoupling the code




•   With Symfony2, the new API of the Facade Pattern is a service

•   Create a bundle for every « module » you identified.

•   Create a service for every bundle you now have, that will serve as
    your Facade API

•   … and start using these services!




                                          19/03/2013   46   THEODO
Example: Model services
          Decoupling the code


namespace MyCompanyMyFreshBundleServices;

class PostService
{
  public function getById($postId)
  {
    $post = PostTable::strangeLegacyMethodById($postId);

        return $post;
    }

}




                                             19/03/2013   47   THEODO
Migrating the model and data




        19/03/2013   48   THEODO
A typical MySQL database is highly coupled
Migrating the model and data




                                19/03/2013   49   THEODO
Decoupling a relational DB is like attacking a giant monster
Migrating the model and data




                                  19/03/2013   50   THEODO
The classical solution is syncing two versions of the data
Migrating the model and data




 •   Syncing can be done with ETL tools like Kettle or with custom code in
     the new application

 •   To avoid unbearable headaches, it is highly recommended to write in
     only one DB. Which means to rewrite parts of the legacy code to save,
     update and delete in the new DB

                                         19/03/2013   51   THEODO
A « bearable headache » solution:
Migrating the model and data




    Legacy Application
                                               New application

                               Routing
                                         19/03/2013   52   THEODO
A « bearable headache » solution:
Migrating the model and data




    Legacy Application
                                               New application

                               Routing
                                         19/03/2013   53   THEODO
MongoDB and DoctrineODM make it (a little) easier
     Migrating the model and data




•   Remember: progressive rewrite relies on decoupling, just like scaling.
    Non-relational DBs make partial evolutions easier in the long-term

•   In a document DB like MongoDB you can have in the same collection
    data which coexist in different versions.

•   To migrate them « just in time » use /** @MongoDBPreLoad */ from
    the Doctrine ODM




                                           19/03/2013   54   THEODO
The need for progressive rewrite

The technical challenges and our solutions

The future




                            19/03/2013   55   THEODO
The evolution of Theodo Evolution
    Theodo Evolution strategy




•   The Theodo team is working currently on 6 progressive rewrites of
    huge applications to Symfony2

•   Every technical solution for progressive rewrite to Symfony2 is
    bundled in our project Theodo Evolution

•   The goal: make it an out-of-the-box solution to work on legacy apps
    without touching legacy code




                                          19/03/2013   56   THEODO
How you can profit from Theodo Evolution?
    Theodo Evolution strategy




•   Some Theodo Evolution bundles will be open-
    sourced.

•   SessionIntegrationBundle is being polished
    right now by Pierre-Henri and Marek

•   Contact us @theodo or fabriceb@theodo.fr




                                         19/03/2013   57   THEODO
Questions ?
            fabriceb@theodo.fr
                     @theodo
                 www.theodo.fr


Feedback: https://joind.in/8391



          19/03/2013   58   THEODO

More Related Content

What's hot

How Drupal 8 Reaches Its Full Potential on Pantheon
How Drupal 8 Reaches Its Full Potential on PantheonHow Drupal 8 Reaches Its Full Potential on Pantheon
How Drupal 8 Reaches Its Full Potential on PantheonPantheon
 
UKLUG 2012 - XPages Extensibility API - going deep!
UKLUG 2012 - XPages Extensibility API - going deep!UKLUG 2012 - XPages Extensibility API - going deep!
UKLUG 2012 - XPages Extensibility API - going deep!René Winkelmeyer
 
SnapyX
SnapyXSnapyX
SnapyXekino
 
Configuration Deployment in Drupal 8
Configuration Deployment in Drupal 8Configuration Deployment in Drupal 8
Configuration Deployment in Drupal 8Manifesto Digital
 
Infrastructure as Data with Ansible
Infrastructure as Data with AnsibleInfrastructure as Data with Ansible
Infrastructure as Data with AnsibleCarlo Bonamico
 
Ask Us Anything: Dries Buytaert and Team Tell All on Drupal 8
Ask Us Anything: Dries Buytaert and Team Tell All on Drupal 8Ask Us Anything: Dries Buytaert and Team Tell All on Drupal 8
Ask Us Anything: Dries Buytaert and Team Tell All on Drupal 8Acquia
 
Responsive & Ready: Why Drupal 8 is Ideal for Building Mobile-first Experienc...
Responsive & Ready: Why Drupal 8 is Ideal for Building Mobile-first Experienc...Responsive & Ready: Why Drupal 8 is Ideal for Building Mobile-first Experienc...
Responsive & Ready: Why Drupal 8 is Ideal for Building Mobile-first Experienc...Acquia
 
NCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsNCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsJohn M. Wargo
 
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...César Hernández
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleRusty Klophaus
 
Drupal 8 Adoption Myths Debunked
Drupal 8 Adoption Myths DebunkedDrupal 8 Adoption Myths Debunked
Drupal 8 Adoption Myths DebunkedAngela Byron
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014Carlo Bonamico
 
Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Pantheon
 
Migrating to Git: Rethinking the Commit
Migrating to Git:  Rethinking the CommitMigrating to Git:  Rethinking the Commit
Migrating to Git: Rethinking the CommitKim Moir
 

What's hot (20)

How Drupal 8 Reaches Its Full Potential on Pantheon
How Drupal 8 Reaches Its Full Potential on PantheonHow Drupal 8 Reaches Its Full Potential on Pantheon
How Drupal 8 Reaches Its Full Potential on Pantheon
 
UKLUG 2012 - XPages Extensibility API - going deep!
UKLUG 2012 - XPages Extensibility API - going deep!UKLUG 2012 - XPages Extensibility API - going deep!
UKLUG 2012 - XPages Extensibility API - going deep!
 
SnapyX
SnapyXSnapyX
SnapyX
 
Configuration Deployment in Drupal 8
Configuration Deployment in Drupal 8Configuration Deployment in Drupal 8
Configuration Deployment in Drupal 8
 
Infrastructure as Data with Ansible
Infrastructure as Data with AnsibleInfrastructure as Data with Ansible
Infrastructure as Data with Ansible
 
Phalcon - Giant Killer
Phalcon - Giant KillerPhalcon - Giant Killer
Phalcon - Giant Killer
 
Ask Us Anything: Dries Buytaert and Team Tell All on Drupal 8
Ask Us Anything: Dries Buytaert and Team Tell All on Drupal 8Ask Us Anything: Dries Buytaert and Team Tell All on Drupal 8
Ask Us Anything: Dries Buytaert and Team Tell All on Drupal 8
 
Future of Grails
Future of GrailsFuture of Grails
Future of Grails
 
Responsive & Ready: Why Drupal 8 is Ideal for Building Mobile-first Experienc...
Responsive & Ready: Why Drupal 8 is Ideal for Building Mobile-first Experienc...Responsive & Ready: Why Drupal 8 is Ideal for Building Mobile-first Experienc...
Responsive & Ready: Why Drupal 8 is Ideal for Building Mobile-first Experienc...
 
NCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile AppsNCDevCon 2017 - Cross Platform Mobile Apps
NCDevCon 2017 - Cross Platform Mobile Apps
 
Upgrading to Drupal 9
Upgrading to Drupal 9Upgrading to Drupal 9
Upgrading to Drupal 9
 
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test Cycle
 
Drupal 8 Adoption Myths Debunked
Drupal 8 Adoption Myths DebunkedDrupal 8 Adoption Myths Debunked
Drupal 8 Adoption Myths Debunked
 
DevOps Note 20120224
DevOps Note 20120224DevOps Note 20120224
DevOps Note 20120224
 
Devops For Drupal
Devops  For DrupalDevops  For Drupal
Devops For Drupal
 
معرفی و ساخت یک فریم‌ورک شخصی به کمک لاراول
معرفی و ساخت یک فریم‌ورک شخصی به کمک لاراولمعرفی و ساخت یک فریم‌ورک شخصی به کمک لاراول
معرفی و ساخت یک فریم‌ورک شخصی به کمک لاراول
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development
 
Migrating to Git: Rethinking the Commit
Migrating to Git:  Rethinking the CommitMigrating to Git:  Rethinking the Commit
Migrating to Git: Rethinking the Commit
 

Viewers also liked

Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011Alessandro Nadalin
 
SilverShop and Omnipay Slides
SilverShop and Omnipay SlidesSilverShop and Omnipay Slides
SilverShop and Omnipay SlidesRoman Schmid
 
Very lastroom symfony1 vers symfony2 en douceur
Very lastroom   symfony1 vers symfony2 en douceurVery lastroom   symfony1 vers symfony2 en douceur
Very lastroom symfony1 vers symfony2 en douceurSébastien Houzé
 
Il était une fois le Continuous Delivery chez Meetic
Il était une fois le Continuous Delivery chez MeeticIl était une fois le Continuous Delivery chez Meetic
Il était une fois le Continuous Delivery chez MeeticJoris Calabrese
 
Migrating to Symfony 3.0
Migrating to Symfony 3.0Migrating to Symfony 3.0
Migrating to Symfony 3.0nicolas.grekas
 
La migration continue vers Symfony
La migration continue vers SymfonyLa migration continue vers Symfony
La migration continue vers SymfonyFrancois Zaninotto
 

Viewers also liked (6)

Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011 Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
Be lazy, be ESI: HTTP caching and Symfony2 @ PHPDay 2011 05-13-2011
 
SilverShop and Omnipay Slides
SilverShop and Omnipay SlidesSilverShop and Omnipay Slides
SilverShop and Omnipay Slides
 
Very lastroom symfony1 vers symfony2 en douceur
Very lastroom   symfony1 vers symfony2 en douceurVery lastroom   symfony1 vers symfony2 en douceur
Very lastroom symfony1 vers symfony2 en douceur
 
Il était une fois le Continuous Delivery chez Meetic
Il était une fois le Continuous Delivery chez MeeticIl était une fois le Continuous Delivery chez Meetic
Il était une fois le Continuous Delivery chez Meetic
 
Migrating to Symfony 3.0
Migrating to Symfony 3.0Migrating to Symfony 3.0
Migrating to Symfony 3.0
 
La migration continue vers Symfony
La migration continue vers SymfonyLa migration continue vers Symfony
La migration continue vers Symfony
 

Similar to Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Conference 2013

JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...
JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...
JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...Andrey Sadovykh
 
Mind your App Footprint 🐾⚡️🌱 (@FlutterConn 2023)
Mind your App Footprint 🐾⚡️🌱 (@FlutterConn 2023)Mind your App Footprint 🐾⚡️🌱 (@FlutterConn 2023)
Mind your App Footprint 🐾⚡️🌱 (@FlutterConn 2023)François
 
Clone Clone Make: a better way to build
Clone Clone Make: a better way to buildClone Clone Make: a better way to build
Clone Clone Make: a better way to buildDanHeidinga
 
Refactoring to GO modules
Refactoring to GO modulesRefactoring to GO modules
Refactoring to GO modulesElad Hirsch
 
Plastic SCM: Entreprise Version Control Platform for Modern Applications and ...
Plastic SCM: Entreprise Version Control Platform for Modern Applications and ...Plastic SCM: Entreprise Version Control Platform for Modern Applications and ...
Plastic SCM: Entreprise Version Control Platform for Modern Applications and ...Kiko Monteverde
 
Twelve Factor - Designing for Change
Twelve Factor - Designing for ChangeTwelve Factor - Designing for Change
Twelve Factor - Designing for ChangeEric Wyles
 
Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015Mirco Hering
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Theo Jungeblut
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...Joe Ferguson
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016Joe Ferguson
 
OSGi Alliance Community Event 2007 - Business Session#2 - Abdallah Bushnaq, A...
OSGi Alliance Community Event 2007 - Business Session#2 - Abdallah Bushnaq, A...OSGi Alliance Community Event 2007 - Business Session#2 - Abdallah Bushnaq, A...
OSGi Alliance Community Event 2007 - Business Session#2 - Abdallah Bushnaq, A...mfrancis
 
Pain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakPain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakSigma Software
 
How dvcs can reduce your development costs and enhance productivity final
How dvcs can reduce your development costs and enhance productivity finalHow dvcs can reduce your development costs and enhance productivity final
How dvcs can reduce your development costs and enhance productivity finalpsluaces
 
Workshop About Software Engineering Skills 2019
Workshop About Software Engineering Skills 2019Workshop About Software Engineering Skills 2019
Workshop About Software Engineering Skills 2019PhuocNT (Fresher.VN)
 
Why we don’t use the Term DevOps: the Journey to a Product Mindset - DevOpsCo...
Why we don’t use the Term DevOps: the Journey to a Product Mindset - DevOpsCo...Why we don’t use the Term DevOps: the Journey to a Product Mindset - DevOpsCo...
Why we don’t use the Term DevOps: the Journey to a Product Mindset - DevOpsCo...Henning Jacobs
 
Fifteen Years of DevOps -- LISA 2012 keynote
Fifteen Years of DevOps -- LISA 2012 keynoteFifteen Years of DevOps -- LISA 2012 keynote
Fifteen Years of DevOps -- LISA 2012 keynoteGeoff Halprin
 
Building of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingBuilding of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingPVS-Studio
 
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in productionNETFest
 

Similar to Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Conference 2013 (20)

JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...
JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...
JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...
 
Mind your App Footprint 🐾⚡️🌱 (@FlutterConn 2023)
Mind your App Footprint 🐾⚡️🌱 (@FlutterConn 2023)Mind your App Footprint 🐾⚡️🌱 (@FlutterConn 2023)
Mind your App Footprint 🐾⚡️🌱 (@FlutterConn 2023)
 
Clone Clone Make: a better way to build
Clone Clone Make: a better way to buildClone Clone Make: a better way to build
Clone Clone Make: a better way to build
 
Refactoring to GO modules
Refactoring to GO modulesRefactoring to GO modules
Refactoring to GO modules
 
Plastic SCM: Entreprise Version Control Platform for Modern Applications and ...
Plastic SCM: Entreprise Version Control Platform for Modern Applications and ...Plastic SCM: Entreprise Version Control Platform for Modern Applications and ...
Plastic SCM: Entreprise Version Control Platform for Modern Applications and ...
 
Twelve Factor - Designing for Change
Twelve Factor - Designing for ChangeTwelve Factor - Designing for Change
Twelve Factor - Designing for Change
 
Advanced deployment scenarios
Advanced deployment scenariosAdvanced deployment scenarios
Advanced deployment scenarios
 
Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015
 
X Means Y
X Means YX Means Y
X Means Y
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016
 
OSGi Alliance Community Event 2007 - Business Session#2 - Abdallah Bushnaq, A...
OSGi Alliance Community Event 2007 - Business Session#2 - Abdallah Bushnaq, A...OSGi Alliance Community Event 2007 - Business Session#2 - Abdallah Bushnaq, A...
OSGi Alliance Community Event 2007 - Business Session#2 - Abdallah Bushnaq, A...
 
Pain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakPain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr Sugak
 
How dvcs can reduce your development costs and enhance productivity final
How dvcs can reduce your development costs and enhance productivity finalHow dvcs can reduce your development costs and enhance productivity final
How dvcs can reduce your development costs and enhance productivity final
 
Workshop About Software Engineering Skills 2019
Workshop About Software Engineering Skills 2019Workshop About Software Engineering Skills 2019
Workshop About Software Engineering Skills 2019
 
Why we don’t use the Term DevOps: the Journey to a Product Mindset - DevOpsCo...
Why we don’t use the Term DevOps: the Journey to a Product Mindset - DevOpsCo...Why we don’t use the Term DevOps: the Journey to a Product Mindset - DevOpsCo...
Why we don’t use the Term DevOps: the Journey to a Product Mindset - DevOpsCo...
 
Fifteen Years of DevOps -- LISA 2012 keynote
Fifteen Years of DevOps -- LISA 2012 keynoteFifteen Years of DevOps -- LISA 2012 keynote
Fifteen Years of DevOps -- LISA 2012 keynote
 
Building of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingBuilding of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code logging
 
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
 

Recently uploaded

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
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
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
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
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 

Recently uploaded (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
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 ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Modernisation of legacy PHP applications using Symfony2 - PHP Northeast Conference 2013

  • 1. Modernisation of legacy PHP applications using Symfony2 19/03/2013 1 THEODO
  • 2. The need for progressive rewrite The technical challenges and our solutions The future 19/03/2013 2 THEODO
  • 3. Legacy PHP applications are everywhere History of PHP applications • 79% : websites written in PHP among the top 1 million, according to W3Techs.com • 1994: PHP was created • 2004: PHP5 was released. Start of OOP • 2007: ZF 1.0.0 and SF 1.0 were released. Start of the MVC age 13 years of (mostly) spagetthi-coded web-apps 19/03/2013 3 THEODO
  • 4. What is the problem of legacy applications? The need for rewrite 19/03/2013 4 THEODO
  • 5. Starting a new version from scratch is a danger to the business The dangers of total rewrite • New developments are invisible until the new version is finished • You need twice more developers: one team to maintain the old application, while the second team is writing the new version • The probability of forgetting features during the rewrite is high • Transition when the new version is ready becomes costly and very dangerous: everything is impacted at once 19/03/2013 5 THEODO
  • 6. More dangerous than you think! The black swan blindness A study led by two Oxford professors on 1,471 IT projects found out that: • 1 project out of 6 ended up costing on average 3 times as much! • large-scale computer spending were 20 times more likely to spiral out of control than expected. Large-scale examples: • the complete revamp of Levi Strauss’ IT, which cost them 192.5 million$ losses • FoxMeyer Drugs’ bankruptcy after switching brutally to SAP Study: http://users.ox.ac.uk/~mast2876/WP_2011_08_15.pdf Fox-Meyer bankruptcy: http://fr.slideshare.net/jmramireza/the-foxmeyer-drugs-bankruptcy-was-it-a-failure- of-erp-2332065 19/03/2013 6 THEODO
  • 7. Progressive rewrite is the solution… but is very challenging The challenge of progressive rewrite • You have to work with hard-to-read code • All the aspects of an application in production are concerned:  source code of course  system  data  cache  remote webservices, etc. • The major conceptual challenge in all those aspects is decoupling of modules. Just like in scaling! 19/03/2013 7 THEODO
  • 8. Progressive rewrite is more profitable Unbeatable time-to-market Functionalities Functionalities Evolution Time Time • No new features for months • Only 1 app to maintain • 2 apps to maintain • Lower regression risks • Unbeatable time-to-market 19/03/2013 8 THEODO
  • 9. The need for progressive rewrite The technical challenges and our solutions The future 19/03/2013 9 THEODO
  • 10. Theodo Evolution Our solution at Theodo • R&D project started at Theodo in 2012 • Aims to solve all these issues to make app rewriting agile again • Our dream: be able to code evolutions on the legacy application without touching the legacy code. 19/03/2013 10 THEODO
  • 11. The technical experts behind Theodo Evolution Theodo Evolution team 19/03/2013 11 THEODO
  • 12. The big picture of the different technical aspects to solve The technical challenges • Preventing regressions • Upgrading the system • Routing • Sharing the layout • Sharing the session/authentication • Decoupling the code • Migrating the model and data 19/03/2013 12 THEODO
  • 14. Belt and straps are necessary… and won’t be enough… Preventing regressions 19/03/2013 14 THEODO
  • 15. Functionally test what could harm your business Preventing regressions • By definition, spaghetti code is deeply coupled. Touching one part breaks something at the other end • Create functional tests on the most critical scenarios • Mink + ZombieJS: https://github.com/Behat/Mink 19/03/2013 15 THEODO
  • 16. Setup good monitoring Preventing regressions The most thorough functional testing is done... by putting in production! • Monitor production well. • Errors 500, 404 • response time with Pingdom • newrelic • Make everybody aware of the heightened risks • Monitor business metrics with StatsD, give the marketing team a Graphite dashboard => get free high-level monitoring! 19/03/2013 16 THEODO
  • 17. And create a fast and easy deployment pipeline Preventing regressions • Deploy often and small updates. Aim ten a day, not just one a week! • Setup a fast rollback system • Setup a fast deployment system, because you want to make it faster to correct small problems than to rollback 19/03/2013 17 THEODO
  • 18. Simple automated deployment with Fabric Automated deployment @roles('prod') def deploy(): tag = "%s/%s" % (_getrole(), strftime("%Y/%m-%d-%H-%M-%S")) local('git tag -a %s -m "%s"' % (tag, _getrole())) local('git push --tags') run('git fetch’) run('git fetch origin --tags') tag = run('git tag -l %s/* | sort | tail -n1' % _getrole()) run('git checkout ' + tag) run('php composer.phar install') 19/03/2013 18 THEODO
  • 20. Migrate to a modern environment that supports Symfony2 …and improves performance as a bonus. Upgrading the system • Symfony2 requires: • PHP 5.3.3 • Sqlite3, JSON, ctype • date.timezone set in php.ini • php app/check.php 19/03/2013 20 THEODO
  • 21. Check that the legacy code will support PHP 5.3/5.4 Upgrading the system • Phpcs CodeSniffs for 5.3 and 5.4 compatibility: https://github.com/wimg/PHPCompatibility • Setup a pre-production environment in the upgraded environment and run your functional tests on it • And this time provision your environment with Puppet or Chef! Check Blueprint: https://github.com/devstructure/blueprint 19/03/2013 21 THEODO
  • 22. Routing 19/03/2013 22 THEODO
  • 23. Routing between the old and the new Routing • The beauty of PHP: some legacy apps have simply no routing system! • Host the new app next to the old app, with clear URL differences, and proxy at the server level • Subdomain: v2.myapp.com • Subfolder: www.myapp.com/v2/ • My favourite: create a catchall route with Symfony2 19/03/2013 23 THEODO
  • 24. The CatchAll Route Routing class LegacyController extends Controller { /** * @Route("/{filename}.php", name="_proxy") */ public function proxyAction($filename) { ob_start(); include $filename . '.php'; // Replace exit()s and die()s // or you might never end up here return new Response(ob_get_clean()); } } 19/03/2013 24 THEODO
  • 26. For end-users « progressive rewrite » = « same template » Sharing the layout • Copy-pasting the layout is not a good solution • Our solution : crawl the legacy layout and include it as ESIs <esi:include src="{{ path('legacylayout_top') }}" /> {% block body %}{% endblock %} <esi:include src="{{ path('legacylayout_bottom') }}" /> 19/03/2013 26 THEODO
  • 27. The « crawling » part of the ESI sub-request Sharing the layout $this->client->setHeader('Cookie', $currentCookie); if ($request->headers->has('authorization')) { $this->client->setHeader( 'Authorization', $request->headers->get('authorization') ); } if ($this->session->isStarted()) { $this->session->save(); } $this->client->request('GET', $url); $esiContent = $this->client->getResponse()->getContent(); 19/03/2013 27 THEODO
  • 28. Sharing the session/authentication 19/03/2013 28 THEODO
  • 29. Make the legacy session accessible from Symfony2 Sharing the session/authentication • You want to access what your legacy app has put in the session from within Symfony2… • BUT Symfony2 expects session information to be neatly stored in arrays in the « _sf2_attributes » namespace to make your legacy session accessible, you need to : • register « Bags » for each of your legacy $_SESSION keys • create a « ScalarBag » type when these values are not arrays 19/03/2013 29 THEODO
  • 30. Example for a Symfony1 Session Sharing the session/authentication // onKernelRequest foreach ( array('symfony/user/sfUser/credentials', 'symfony/user/sfUser/attributes’) as $namespace) { $bag = new NamespacedAttributeBag($namespace, '.'); $bag->setName($namespace); $session->registerBag($bag); } 19/03/2013 30 THEODO
  • 32. Attacking the spaghetti problem Decoupling the code 19/03/2013 32 THEODO
  • 33. Decoupling is a major aspect of progressive rewrite Decoupling the code 19/03/2013 33 THEODO
  • 34. Decoupling is a major aspect of progressive rewrite Decoupling the code 19/03/2013 34 THEODO
  • 35. Decoupling is a major aspect of progressive rewrite Decoupling the code 19/03/2013 35 THEODO
  • 36. Decoupling is a major aspect of progressive rewrite Decoupling the code 19/03/2013 36 THEODO
  • 37. Decoupling is a major aspect of progressive rewrite Decoupling the code 19/03/2013 37 THEODO
  • 38. Decoupling is a major aspect of progressive rewrite Decoupling the code 19/03/2013 38 THEODO
  • 39. The dream architecture Decoupling the code 19/03/2013 39 THEODO
  • 40. What you usually find Decoupling the code 19/03/2013 40 THEODO
  • 41. You need to create the dream API and slowly refactor around it Decoupling the code A A P P I A I P I A P I A P I A A P P I I 19/03/2013 41 THEODO
  • 42. You need to create the dream API and slowly refactor around it Decoupling the code A A P P I A I P I A P I A P I A A P P I I 19/03/2013 42 THEODO
  • 43. You need to create the dream API and slowly refactor around it Decoupling the code A A P P I A I P I A P I A P I A A P P I I 19/03/2013 43 THEODO
  • 44. You need to create the dream API and slowly refactor around it Decoupling the code A A P P I A I P I A P I A P I A A P P I I 19/03/2013 44 THEODO
  • 45. This is called « Facade Pattern » Decoupling the code Wikipedia A facade is an object that provides a simplified interface to a larger body of code, such as a class library. […] A façade reduces dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system; 19/03/2013 45 THEODO
  • 46. Symfony2 Service Container Decoupling the code • With Symfony2, the new API of the Facade Pattern is a service • Create a bundle for every « module » you identified. • Create a service for every bundle you now have, that will serve as your Facade API • … and start using these services! 19/03/2013 46 THEODO
  • 47. Example: Model services Decoupling the code namespace MyCompanyMyFreshBundleServices; class PostService { public function getById($postId) { $post = PostTable::strangeLegacyMethodById($postId); return $post; } } 19/03/2013 47 THEODO
  • 48. Migrating the model and data 19/03/2013 48 THEODO
  • 49. A typical MySQL database is highly coupled Migrating the model and data 19/03/2013 49 THEODO
  • 50. Decoupling a relational DB is like attacking a giant monster Migrating the model and data 19/03/2013 50 THEODO
  • 51. The classical solution is syncing two versions of the data Migrating the model and data • Syncing can be done with ETL tools like Kettle or with custom code in the new application • To avoid unbearable headaches, it is highly recommended to write in only one DB. Which means to rewrite parts of the legacy code to save, update and delete in the new DB 19/03/2013 51 THEODO
  • 52. A « bearable headache » solution: Migrating the model and data Legacy Application New application Routing 19/03/2013 52 THEODO
  • 53. A « bearable headache » solution: Migrating the model and data Legacy Application New application Routing 19/03/2013 53 THEODO
  • 54. MongoDB and DoctrineODM make it (a little) easier Migrating the model and data • Remember: progressive rewrite relies on decoupling, just like scaling. Non-relational DBs make partial evolutions easier in the long-term • In a document DB like MongoDB you can have in the same collection data which coexist in different versions. • To migrate them « just in time » use /** @MongoDBPreLoad */ from the Doctrine ODM 19/03/2013 54 THEODO
  • 55. The need for progressive rewrite The technical challenges and our solutions The future 19/03/2013 55 THEODO
  • 56. The evolution of Theodo Evolution Theodo Evolution strategy • The Theodo team is working currently on 6 progressive rewrites of huge applications to Symfony2 • Every technical solution for progressive rewrite to Symfony2 is bundled in our project Theodo Evolution • The goal: make it an out-of-the-box solution to work on legacy apps without touching legacy code 19/03/2013 56 THEODO
  • 57. How you can profit from Theodo Evolution? Theodo Evolution strategy • Some Theodo Evolution bundles will be open- sourced. • SessionIntegrationBundle is being polished right now by Pierre-Henri and Marek • Contact us @theodo or fabriceb@theodo.fr 19/03/2013 57 THEODO
  • 58. Questions ? fabriceb@theodo.fr @theodo www.theodo.fr Feedback: https://joind.in/8391 19/03/2013 58 THEODO