Legacy PHP To Top Notch Code

Tue May 07 2019

Tech Stack: PHP, Laravel, Slim, Composer, docker While joining an old experienced team with a great product that exists for several years for creating some new features. I noticed the codebase problems and time waste it caused the rest of team and myself. We initially all worked locally and synced the code to a cloud server to test our changes. This process was slow and had a lot of problems for all of us. My first step was to create a replica of the stack in the docker and share the working local environment with the rest of team for feedback. That passed through great.

The Legacy Code The product was amazing and it supported great features. But for any new feature, we needed to do a lot of changes and surely didnt care from DRY principle (dont repeat yourself). The code had four different entry-points to the app and each entry point had each own routes. Authentication was reimplemented in different ways and were duplicated on each route code.

What we did:

  • Started using Laravel DI container
  • Added middlewares for:
    • authentication
    • data validation
    • env setup, current account, current user, etc
  • Added the use of Controllers instead of anonymous functions
  • Used Created common function for handling responses and errors