Published on February 22, 2014
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 ﬁles • 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, ﬁxing bugs • Using new technologies
Making life easier, not a priority • "We can ﬁx 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 • Deﬁning 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 ﬁles for conﬁguration
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 • github.com/o
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.
... the system consists completely of legacy code. ... program transformation by software modernization enterprises have made the legacy ...
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, ...
Rewrite your legacy PHP ... So retain good legacy code by encapsulating it and don't ... Modernizing Legacy Applications In PHP; Modernising the Legacy;
Modernising Legacy Systems: Managed Evolution ... Wir analysieren Ihren Code in einer ersten Runde. Wir identifizieren mögliche Services. Workshop
... modernising legacy code; managing large codebases; ... Back-end PHP development using Zend MVC and PHPUnit for Test Driven Development (TDD).
Welcome to MigrationWare. ... MigrationWare specialises in modernising legacy code and ageing IT infrastructure by transforming and extending existing ...
This is achieved by transforming and modernising legacy code and architecture, ... Top banks respond to growing competition by modernising legacy systems;
Bonede Alliance assists ... on a wide range of legacy and ... applications by transforming and modernising legacy code and ...