Modernising legacy code in PHP

50 %
50 %
Information about Modernising legacy code in PHP

Published on February 22, 2014

Author: Osmanngr



"Adam olacak kod"
Story of modernising a legacy app in PHP

Adam olacak kod Story of modernising a legacy app in PHP

Old code • 150000 lines of code • 90% of code is procedural • No coding convention • No separation of concerns

Old code • Architected over several years • global variables all around • Core of the system was a collection of include files • Mixed-up aggregation of PHP, HTML, SQL, JS, and CSS

Old code • No unit tests • No environment aware • Offensive programming • Lack of error reporting, logging

Its too hard • Understanding logic • Designing anything new • Debugging, fixing bugs • Using new technologies

Making life easier, not a priority • "We can fix it later" • "It works!" • "Cutting and pasting code is faster than refactoring code" • "We do not pay you to write nice code. We pay you to get job done"

Writing from scratch, Part 1 • As a REST API ! • Written in 4 months • 15000 lines of code

First days • Include hell still exists • Big picture problem • Context-Switching • Knowledge problem

We can’t use a framework • Using PHP 5.1 in production (lately upgraded to 5.4) • Finding a compatible modern library is hard (Thanks to PHP_CompatInfo) • Missing features (namespaces, LSB, closures, traits, generators) • Working with same environment is impossible

Core refactoring • Autoloader implementation • Error handling • Logging (ported from SlimLog, after replaced with Monolog) • DB Abstraction (derived from DoctrineDBAL Connection)

Core refactoring • Replace global w/ Dependency Injection • Environment aware behaviours • Common exceptions • Request lifecycle (routing, request, response)

Extracting procedural code to MVC • Defining endpoints • SQL Queries • Business logic • Validations

Part 2, Frontend • Custom Symfony2 Kernel ! • Written in 2 months • 30000 lines of code

Frontend • Top of SymfonyHttpKernel • Basically, Symfony2 without bundles • Enhancements for FrameworkBundle • Rapid Application Development (minimal planning in favor of rapid prototyping)

Frontend • Accelerates development processes • Shorter notations (routes, templates) • Guzzle for talking with API • Uses YAML files for configuration

Frontend • Heavy usage of IoC and Event Dispatcher • Twig as a templating engine • Monolog for logging • Custom (shallow) directory structure

Why REST? • Separation of concerns • Scalability and performance (Easier to scale horizontally and vertically) • Caching (Eliminates some client–server interactions) • Portability and simplicity (Replaced and developed independently)

Concerns for a good REST API • Fine grained resources • Versioning • Authorization • Sensible HTTP status codes

Thanks • Osman Ungur •

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Modernizing Legacy… by Paul M. Jones [PDF/iPad/Kindle]

Modernizing Legacy Applications In PHP Get your code under control in a series of small, ... "Modernizing Legacy Applications in PHP" is the book for you.
Read more

Software modernization - Wikipedia, the free encyclopedia

... the system consists completely of legacy code. ... program transformation by software modernization enterprises have made the legacy ...
Read more

Modernising the Legacy - PHP Summer Camp 2015

Modernising the Legacy. ... Marek is a PHP/Symfony developer at SensioLabs UK with over 10 years of ... Learn how to work with the legacy code, ...
Read more

Rewrite your legacy PHP apps in... PHP! -

Rewrite your legacy PHP ... So retain good legacy code by encapsulating it and don't ... Modernizing Legacy Applications In PHP; Modernising the Legacy;
Read more

Modernising Legacy Systems Service-orientierte Lösungen

Modernising Legacy Systems: Managed Evolution ... Wir analysieren Ihren Code in einer ersten Runde. Wir identifizieren mögliche Services. Workshop
Read more

Sam Burns | LinkedIn

... modernising legacy code; managing large codebases; ... Back-end PHP development using Zend MVC and PHPUnit for Test Driven Development (TDD).
Read more

Welcome to MigrationWare - MigrationWare - Technology that ...

Welcome to MigrationWare. ... MigrationWare specialises in modernising legacy code and ageing IT infrastructure by transforming and extending existing ...
Read more

MigrationWare - Technology that moves you: - The company

This is achieved by transforming and modernising legacy code and architecture, ... Top banks respond to growing competition by modernising legacy systems;
Read more

About Bonede Alliance

Bonede Alliance assists ... on a wide range of legacy and ... applications by transforming and modernising legacy code and ...
Read more