How to eat an ElePHPant: Modernize legacy PHP Applications

Presented on2023-10-13

How to eat an ElePHPant: How to modernize your legacy PHP Applications

How to eat an ElePHPant: How to modernize your legacy PHP Applications
A new PHP version is released every year, that brings new features, removals, as well as breaking-changes that can be overwhelming for PHP applications that didn't keep up to date for a while.

Still running that PHP 5.4 application with no Composer autoloading in sight? Stuck in PHP 7.4 because PHP 8.0 is too steep of a jump? Tired of "if it works don't touch it" mantra? This talk might be just the right fit!

The more PHP evolves, the harder it can get to keep up with the latest changes in PHP. At the same time, almost every new PHP version brings performance and security improvements that legacy applications miss.

This talk borrows the wisdom of Desmond Tuto on how to eat an elephant ElePHPant: A bite at a time. Rewriting a PHP application entirely, especially when it's a legacy PHP application with a lot of edge cases can end up in a worse code, so the ideal way of modernizing a PHP application would be selectively upgrading it. Taking examples from Drupal 7's major upgrade to the modern Drupal code base today, as well as other practical and real-life use cases, this talk aims to be actionable, practical, and inspiring.

Some of the approaches and steps discussed in this talk includes:

  • Gradually add proper error and exception handling
  • Integrating a Dependency Injection Container
  • Moving away from static PHP URLs and web-server URL rewrites to a single route handler design
  • Incorporating Composer while getting rid of random scattered include/require directives
  • Configuration management and separation
  • Making code composable
  • Using Object-Oriented Coding patterns where appropriate
  • Gradually integrating templating systems

Additionally, this talk also discusses about lengthening the lifetime of legacy PHP applications in case the applications are not planned to be upgraded, and are only necessary to be run as long as they securely can be. Most of the inspiration for this section of the talk is from the speaker's blog post on How to extend lifetime of legacy PHP applications


Download PDF | Joind.In